Is there a way to modify the directory under which the maven build cache artifacts are stored locally when no remote server is used per execution, so ideally from the command line when running maven?
By default it is stored under ~/.m2/build-cache
- is there any way to change that with a command line parameter when running maven?
Turns out, you cannot specifically set the build cache directory via the command line. However, the default location is defined relative to the regular maven repository directory. So if you change the repository directory to ~/custom-maven-dir/repository
via
-Dmaven.repo.local=~/custom-maven-dir/repository/
then the build cache directory will be at ~/custom-maven-dir/build-cache
Thanks to https://stackoverflow.com/users/296328/khmarbaise for pointing me to the documentation that had the information about the relative default path for the build cache.
Note that you can set a fixed path for the build cache in the build cache extension config file (see https://maven.apache.org/extensions/maven-build-cache-extension/build-cache-config.html#class_local ) However, that is then a static setting for the project not a command line option.