Krishna Chaitanya
Krishna Chaitanya

Reputation: 2663

How to get maven repo location in pom file

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

Upvotes: 8

Views: 7091

Answers (1)

Krishna Chaitanya
Krishna Chaitanya

Reputation: 2663

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.

Upvotes: 17

Related Questions