Configuring and Clearing Maven Build Cache
CodeArts Build allows you to cache the dependencies in your private storage space. Once cached, the dependencies will not have to be pulled for future builds. It greatly accelerates builds.
Configuring Cache Setting
When a build task is created, the cache acceleration build is selected by default. You can determine whether to use the cache when configuring the Maven build action.
Clearing Cache
Network jitter, concurrent builds, or other extreme conditions may result in abnormal cache. Consequently, build errors may occur. The following describes how to clear the abnormal cache.
Before clearing cache, make sure you are well aware of the following precautions:
- The cache directory is shared by multiple users of the same tenant. If the cache is frequently cleared, exceptions (usually xxx file does not exist) may occur during other users' builds. Therefore, this operation can be performed only when the cache is abnormal. After the task succeeds, edit the task to delete the cache clearing command. While clearing the cache, do not run other build tasks that use the 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 be executed only in the Build with Maven action. If this command is executed in other actions, the clearing operation may not succeed or an error will be displayed (for example the directory does not exist).
- Click on the build tasks page.
- 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 format of the cache clearing command is rm -rf /repository/local/maven/{groupId}/{artifactId}/{version}. The parameters to be entered correspond to groupId, artifactId, and version in the dependency package coordinates. The dots in groupId are automatically divided into hierarchical directories.
For example, if the dependency package is as follows:<dependency> <groupId>com.xxx.xxx</groupId> <artifactId>demo</artifactId> <version>1.0.9-SNAPSHOT</version> </dependency>
The command for clearing the package 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.