Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get maven repo location in pom file

Tags:

maven

I have a maven goal which will execute a groovy file. This groovy file uses a path which is like below

System.getProperty("user.home");

This root path is used to build the another path which points to a jar file inside the local repository.

Unfortunately, I don't have permissions in C drive and I am using D drive. So my repository is also in D drive.

Because of this my build failed. To pass my build I am passing a command line arguments to maven like below

mvn clean install -Duser.home=D:\users\krishna

I want to know if there is a pom variable/place-holder something like {m2RepoHome} so that I can use the same variable in my groovy file.

Thanks in advance

like image 967
Krishna Chaitanya Avatar asked Nov 24 '15 10:11

Krishna Chaitanya


People also ask

Where is Maven repository location?

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.

Where do you give the Maven central repository path in Mave POM xml?

Maven local repository by default get created by Maven in %USER_HOME% directory. To override the default location, mention another path in Maven settings. xml file available at %M2_HOME%\conf directory.


1 Answers

Maven provides a convenient place-holder settings.X where X is any element in settings.xml file.

I used ${settings.localRepository} and it worked.

Properties section in https://maven.apache.org/settings.html explains how to use it.

like image 162
Krishna Chaitanya Avatar answered Nov 16 '22 03:11

Krishna Chaitanya