Is there a way to get the Maven local repo location?
Using the following command you can force Maven to use a specific setting file:
mvn -s < path to settings file >
I know you can edit settings.xml
file to set a repository location, but can I get the current default value with some Maven command?
The Maven local repository is located in the /home/. m2 directory, the folder is probably hidden.
The Local Repository is the . git/ subdirectory inside the Working Directory. The Index is a conceptual place that also physically resides in the . git/ subdirectory.
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.
If you want just the local repo, try this:
mvn help:evaluate -Dexpression=settings.localRepository | grep -v '\[INFO\]'
EDIT
I'm revisiting this after years because recent versions of the Maven help plugin introduced a useful parameter for the evaluate
goal called forceStdout
that allows us to remove the need to grep the output:
mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout
Yes, you can get it with the -X
or --debug
option, e.g. mvn -X
... [DEBUG] Reading global settings from C:\Maven\conf\settings.xml [DEBUG] Reading user settings from C:\segphault\.m2\settings.xml [DEBUG] Using local repository at C:\Repo ...
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