Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven: Is it possible to override location of local repository via the use of command line option or env variable?

Tags:

maven-2

maven

Currently we specify the location of local repository in the settings.xml. Is it possible to override this setting via command line or env variable, such that I can use an alternative location sometimes?

like image 735
Anthony Kong Avatar asked Feb 03 '12 02:02

Anthony Kong


People also ask

How do I override Maven central repository?

Because maven uses the id "central" internally for the main repository http://repo1.maven.org/maven2, defining another repository with the same id will override the default definition. Another way to avoid use of the central repository is with the use of mirrors in settings. xml.

Where is Maven repository located in CMD?

For windows users Usually it's in: C:\Users\USER_NAME\. m2\repository . However the mvn help:effective-settings command will surely show the local path in response xml.

What is the different location of local repository in Maven?

The Maven local repository is located in the /home/. m2 directory, the folder is probably hidden.


1 Answers

You would need to specify the maven.repo.local parameter to do this.

mvn package -Dmaven.repo.local=/alternate/repo/location 

Here is a related SO question.

like image 63
Raghuram Avatar answered Oct 03 '22 05:10

Raghuram