[英]Maven build is not using the updated version of model(pom.xml)
我有一個 maven 項目,我確實從用戶那里獲得了新的項目版本:
Current Version = 1.0.0
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>set</goal>
</goals>
</execution>
</executions>
</plugin>
Current Version = 2.0.0
之后我調用了我自己的自定義插件,它運行一組計算並將一個字符串附加到版本
Current Version = 2.0.0
<groupId>mygroup</groupId>
<artifactId>my artifact</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
Current Version = 2.0.0-AddedString
但是當我運行其他插件時,例如:
<groupId>com.github.ekryd.echo-maven-plugin</groupId>
<artifactId>echo-maven-plugin</artifactId>
<executions>
<execution>
<id>end</id>
<goals>
<goal>echo</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<message>${project.version}</message>
</configuration>
</execution>
</executions>
這給了我的結果:“1.0.0”應該是“2.0.0-AddedString”
但為什么? 以及如何解決這個問題? 我需要所有插件都使用新版本並使用它。
您需要為此單獨運行 Maven。
如果您運行類似mvn versions:set -DnewVersion=2.0.0 my:plugin
,那么my:plugin
將看到啟動命令之前的版本,而不是介於兩者之間的2.0.0
。
因此,當您有更改 POM 的目標時,您需要在單獨的 Maven 運行中調用它們,即首先mvn versions:set -DnewVersion=2.0.0
然后mvn my:plugin
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.