Help Center/ CodeArts Build/ User Guide/ References/ Cache Directory Usage
Updated on 2024-12-02 GMT+08:00

Cache Directory Usage

CodeArts Build offers a dependency cache feature in certain build actions, which significantly enhances the efficiency of downloading dependency packages during the build process. When executing the build task, CodeArts Build mounts the remote cache directory specific to the tenant on the build task executor. This directory can be directly utilized during the build process, eliminating the need for repetitive downloads. For build actions that supported caching, see Table 1.

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.
  • For security purposes, the cache clearing command can only be run in the build action. Running this command in other actions may encounter an error (for example, the clearing operation failed or the directory not found).
Table 1 Usage of the cache directory in each Build action

Build Action

Cache Directory (Enter an absolute directory rather than a relative directory starting with ./.)

Cache Usage

Cache Clearing Command

Build with Maven

/repository/local/maven

For details about the GUI configuration, see Building with Maven.

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.codearts.java</groupId>
   <artifactId>demo</artifactId>
   <version>1.0-SNAPSHOT</version> 
</dependency>

The command for clearing the dependency is rm -rf /repository/local/maven/com/codearts/java/demo/1.0-SNAPSHOT.

Build with npm

/npmcache

Input the following build command: npm config set cache /npmcache.

npm cache clean --force

Build with Grunt

/npmcache

Input the following build command: npm config set cache /npmcache.

npm cache clean --force

Build with Gulp

/npmcache

Input the following build command: npm config set cache /npmcache.

npm cache clean --force

Build Android Quick App

/npmcache

Input the following build command: npm config set cache /npmcache.

npm cache clean --force

Build with Yarn

/npmcache

Input the following build command: yarn config set cache-folder /npmcache.

yarn cache clean

Build with Gradle

(Only for the Gradle wrapper version)

./gradle/wrapper

Input the following build command: cp /cache/android/wrapper/gradle-wrapper.jar ./gradle/wrapper/gradle-wrapper.jar.

rm -rf ./gradle/wrapper/

Build with Android

(Only for the Gradle wrapper version)

./gradle/wrapper

Input the following build command: cp /cache/android/wrapper/gradle-wrapper.jar ./gradle/wrapper/gradle-wrapper.jar.

rm -rf ./gradle/wrapper/