Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set .m2 for a single build-job to different location

Tags:

java

maven

For a build-job on a build-server, I want to set the .m2 location to something different from user.home/.m2.

I thought I could trick maven by setting export HOME=$WORKSPACE for the build, but artifacts kept being downloaded and being deployed to the build user's home directory.

Therefore I think that maven uses the user.home system property which seems to not take $HOME into account.

Is there a solution for this? We have a local maven cache, and I do want to download all artifacts for this build-job and prevent any deployment into the build-user's $HOME/.m2 in order to seperate individual build jobs from each other. At least I want this for some jobs.

Any ideas? Thanks in advance!

like image 588
Martin C. Avatar asked May 31 '11 16:05

Martin C.


2 Answers

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

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

From here you can customize anything you would need.

[update] You can even override the "global" settings which are typically merged with the user's settings.xml form their .m2 directory via --global-settings /path/to/global/settings.xml

like image 53
Andrew White Avatar answered Sep 28 '22 05:09

Andrew White


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 maven-1.x website but still works with maven 3.0 - can't find a reliable source for this version though)
like image 20
Colin Hebert Avatar answered Sep 28 '22 04:09

Colin Hebert