Java 如何使用 pom.xml 将参数传递给 maven 构建?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24206013/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to pass parameters to maven build using pom.xml?
提问by Laxman G
I wanted pass maven command line parameter to POM.xml so that i can use those value for some other purpose in building purpose.
我想将 maven 命令行参数传递给 POM.xml,以便我可以将这些值用于构建目的的其他目的。
采纳答案by Laxman G
We can Supply parameter in different way after some search I found some useful
我们可以在一些搜索后以不同的方式提供参数我发现一些有用的
<plugin>
<artifactId>${release.artifactId}</artifactId>
<version>${release.version}-${release.svm.version}</version>...
...
...
Actually in my application I need to save and supply SVN Version as parameter so i have implemented as above .
实际上,在我的应用程序中,我需要保存并提供 SVN 版本作为参数,因此我已按上述方式实现。
While Running build we need supply value for those parameter as follows.
在运行构建时,我们需要为这些参数提供如下值。
RestProj_Bizs>mvn clean install package -Drelease.artifactId=RestAPIBiz -Drelease.version=10.6 -Drelease.svm.version=74
Here I am supplying
我在这里提供
release.artifactId=RestAPIBiz
release.version=10.6
release.svm.version=74
It worked for me. Thanks
它对我有用。谢谢
回答by coreJavare
回答by Laxman G
If we have parameter like below in our POM XML
如果我们的 POM XML 中有如下参数
<version>${project.version}.${svn.version}</version>
<packaging>war</packaging>
I run maven command line as follows :
我运行 maven 命令行如下:
mvn clean install package -Dproject.version=10 -Dsvn.version=1