简体   繁体   English

如何在pom文件中获取maven repo位置

[英]How to get maven repo location in pom file

I have a maven goal which will execute a groovy file. 我有一个maven目标,它将执行一个groovy文件。 This groovy file uses a path which is like below 这个groovy文件使用如下所示的路径

System.getProperty("user.home");

This root path is used to build the another path which points to a jar file inside the local repository. 此根路径用于构建指向本地存储库中的jar文件的另一个路径。

Unfortunately, I don't have permissions in C drive and I am using D drive. 不幸的是,我没有C驱动器的权限,我正在使用D盘。 So my repository is also in D drive. 所以我的存储库也在D盘中。

Because of this my build failed. 因此,我的构建失败了。 To pass my build I am passing a command line arguments to maven like below 为了传递我的构建,我将命令行参数传递给maven,如下所示

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. 我想知道是否有像{m2RepoHome}这样的pom变量/占位符,以便我可以在我的groovy文件中使用相同的变量。

Thanks in advance 提前致谢

Maven provides a convenient place-holder settings.X where X is any element in settings.xml file. Maven提供了方便的占位符settings.X ,其中X是settings.xml文件中的任何元素。

I used ${settings.localRepository} and it worked. 我使用了${settings.localRepository}并且它有效。

Properties section in https://maven.apache.org/settings.html explains how to use it. https://maven.apache.org/settings.html中的“属性”部分介绍了如何使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM