Install .m2 for one build job to another location

To build the job on the build server, I want the location to be .m2different from user.home/.m2.

I thought I could trick maven into installing it export HOME=$WORKSPACEfor the assembly, but artifacts would load and deploy in the assembly user's home directory.

Therefore, I think maven uses a system property user.home, which apparently does not take into account $HOME.

Is there a solution for this? We have a local maven cache, and I want to load all the artifacts for this build job and prevent any deployment in build-user $HOME/.m2in order to separate the individual build jobs from each other. At least I want this to be for some assignments.

Any ideas? Thanks in advance!

+5
source share
2 answers

You can redefine the location of the settings.xml file from the command line ...

mvn <target> --settings /path/to/settings.xml

Here you can customize everything you need.

[update] You can even override the "global" settings, which are usually combined with user settings. xml form their .m2 directory through--global-settings /path/to/global/settings.xml

+6
source

If you just want to specify your own local repository, you can use the option maven.repo.local:

-Dmaven.repo.local=/path/to/your/repository

Resources:

  • maven.apache.org (on the maven-1.x website, but still works with maven 3.0 - cannot find a reliable source for this version though)
+5
source

All Articles