Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the Maven local repo location?

Tags:

maven-2

maven

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?

like image 338
code-gijoe Avatar asked May 06 '11 19:05

code-gijoe


People also ask

Where is my local Maven repository?

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

What is the location of local repository?

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.

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.


2 Answers

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 
like image 130
adutra Avatar answered Sep 21 '22 17:09

adutra


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 ... 
like image 43
Justin Garrick Avatar answered Sep 21 '22 17:09

Justin Garrick