Use the MAVEN_OPTS
environment variable to set the location of your repository. Set it in your shell startup, and you don’t have to put it on the command line every time.
export MAVEN_OPTS="-Dmaven.repo.local=/path/to/repository"
You said you wanted to change the .m2
for the settings.xml
file as well as the repository
directory. You want to set the M2_HOME
environment variable. The Maven settings documentation says that it controls where Maven looks for settings.xml
. From there, you can control the repository location, etc.