英文:
How to set/update multiple property in maven during or before maven build
问题
我的POM结构如下 - 我正在使用org.codehaus.mojo:versions-maven-plugin:2.16.0
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>manchu-core</artifactId>
<version>[${myartifact.version}]</version>
</dependency>
...
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>manchu-extra</artifactId>
<version>[${mysecondArtifact.version}]</version>
</dependency>
现在我想在Maven构建期间为这两个版本的属性设置不同的值。
我尝试过 mvn versions:set-property -Dpropery=myartifact.version -DnewVersion=10.1.1
,但set-property只设置一个属性,不设置两个属性的值。
如果我使用逗号分隔的值传递它,它只接受最后一个属性而不是两个。
mvn versions:set-property -Dpropery=myartifact.version -DnewVersion=10.1.1, -Dpropery=mysecondartifact.version -DnewVersion=10.5.1
是否有其他选项可以用来更新/设置多个属性的值?
提前感谢!
英文:
My pom structure looks like - and i am using org.codehaus.mojo:versions-maven-plugin:2.16.0
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>manchu-core</artifactId>
<version>[${myartifact.version}]</version>
</dependency>
...
<dependency>
<groupId>com.foo.bar</groupId>
<artifactId>manchu-extra</artifactId>
<version>[${mysecondArtifact.version}]</version>
</dependency>
Now i want to set different versions for the property of both versions during Maven build.
i tried mvn versions:set-property -Dpropery=myartifact.version -DnewVersion=10.1.1
, but set-propery only set single property and does not set both property values
if I pass it using comma-separated value, it only takes the last property not both
mvn versions:set-property -Dpropery=myartifact.version -DnewVersion=10.1.1, -Dpropery=mysecondartifact.version -DnewVersion=10.5.1
is there any other option I can use to update/set multiple properties' values?
Thanks in advance
答案1
得分: 1
The versions:set-property命令一次只能更新一个属性。类似这样:
mvn versions:set-property -Dproperty=myartifact.version -DnewVersion=10.1.1
mvn versions:set-property -Dproperty=mysecondArtifact.version -DnewVersion=10.5.1
你也可以创建一个bash脚本,在其中传递两个参数,然后运行上面的两行代码,传递你刚刚设置的值。
你也可以在pom文件中这样设置属性:
<properties>
<myartifact.version>10.1.1</myartifact.version>
<mysecondArtifact.version>10.5.1</mysecondArtifact.version>
</properties>
英文:
The versions:set-property command can only update one property at a time. Something like:
mvn versions:set-property -Dproperty=myartifact.version -DnewVersion=10.1.1
mvn versions:set-property -Dproperty=mysecondArtifact.version -DnewVersion=10.5.1
You potentially could also want to create a bash script in which you pass 2 parameters and run those two lines above with the values you just passed.
You can also set the properties in the pom like this:
<properties>
<myartifact.version>10.1.1</myartifact.version>
<mysecondArtifact.version>10.5.1</mysecondArtifact.version>
</properties>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论