我使用versions-maven插件來更新項目版本。我想安裝這個更新版本的工件,但maven-install插件使用舊版本。如何配置項目以實現所描述的行爲?Maven安裝插件不使用版本插件更新版本
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
<configuration>
<propertyPrefix>parsedVersion</propertyPrefix>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<executions>
<execution>
<id>update-version</id>
<phase>validate</phase>
<goals>
<goal>set</goal>
<goal>commit</goal>
</goals>
<configuration>
<newVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-${SVN_REVISION}</newVersion>
</configuration>
</execution>
</executions>
</plugin>
通常我會想到的是,因爲版本的插件在驗證階段執行有關Maven的生命週期中安裝插件應該採取新的版本。
版本,Maven的插件:設定目標,僅用於內部的命令行運行和NOT lifecycle ...永遠不會工作,導致版本 - maven-plugin:set目標將改變pom.xml文件,但在運行期間,pom.xml已經被加載到內存中,因此結果是你將總是安裝舊的版本。您使用哪個Maven版本? – khmarbaise
嗨,謝謝你的回答,我使用Maven 3.3.x.從命令行使用版本插件後,它的工作!也許有人有相同的用例:build-helper:parse-version版本:set -DnewVersion = $ {parsedVersion.majorVersion}。$ {parsedVersion.minorVersion}。$ {parsedVersion.incrementalVersion} - $ {SVN_REVISION} – desert