How Do I Configure and Clear the Cache for a Maven Build?
CodeArts Build allows you to cache the dependencies in your private storage space, eliminating the need to download them repeatedly for future builds. This speeds up the build process by allowing the dependencies to be used directly from the cache.
Configuring Build Cache
By default, the option to use cache is enabled when you create a build task. You can specify whether to use the cache when configuring the Build with Maven action.
Clearing Cache
Under extreme conditions such as network jitter or concurrent builds, abnormal cache may occur, leading to build errors. In the following section, you will find the steps to clear the abnormal cache.
Before clearing cache, be well aware of the following caveats:
- Since the cache directory is shared among multiple users in the same tenant, frequent clearing of the cache may cause exceptions (usually a message indicating that "xxx file does not exist") for other users during their builds. Therefore, clear the cache only when it is abnormal. Once the task is successful, remove the cache clearing command. While clearing the cache, avoid running other build tasks that use this cache.
- An accurate file path is required for clearing the cache. For example, to clear the demo 1.0.0 of vendor XXX, run the rm -rf /path/com/xxx/demo/1.0.0 command. If the level of the directory entered in the cache clearing command is too high, the next build will be slow or the dependency will be abnormal due to network problems.
- For security purposes, the cache clearing command can only be run in the Build with Maven action. Running this command in other actions may encounter an error (for example, the clearing operation failed or the directory not found).
- Click in the Operation column of the build task.
- Choose mvn xxxx in the commands. . Locate the line starting with
- Enter the cache clearing command in front of mvn xxx and click Save.
The cache clearing command follows this format: rm -rf /repository/local/maven/{groupId}/{artifactId}/{version}. Enter the parameters for groupId, artifactId, and version based on the dependency coordinates. The periods in groupId are automatically converted into directory separators (/) and form a directory structure.
For example, assume that the dependency coordinates are as follows:<dependency> <groupId>com.xxx.xxx</groupId> <artifactId>demo</artifactId> <version>1.0.9-SNAPSHOT</version> </dependency>
The command for clearing the dependency is rm -rf /repository/local/maven/com/xxx/xxx/demo/1.0.9-SNAPSHOT.
- Run the build task again. After the task succeeds, edit the task again and remove the cache clearing command.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot