You can change the default location of . m2 directory in m2. conf file. It resides in your maven installation directory.
Maven local repository is located in your local system. It is created by the maven when you run any maven command. By default, maven local repository is %USER_HOME%/. m2 directory.
The answer above is correct. You can use the "-Dmaven.
use maven property maven.repo.local
:
mvn -Dmaven.repo.local=$HOME/.my/other/repository clean install
No modifications to settings.xml
are necessary.
For git:
alias mvn='mvn "-Dmaven.repo.local=$(git rev-parse --show-toplevel)/.m2/repository"'
This uses a separate maven repository in each git repository
One kind of hacky way that would work is:
<localRepository>${m2.localRepository}</localRepository>
to your settings.xml-Dm2.localRepository=<full path to home dir>/.m2/repository
before the "$@" in the command that gets executed. This will make your default local repo stay where it should be.mvn -Dm2.localRepository=... <phases/goals>
. Because your command line system property gets added to the command line after the one in the mvn script, it will take precedence. (At least I'm pretty sure it works that way on both windows and linux, but testing will tell.)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With