【发布时间】:2023-04-09 03:36:02
【问题描述】:
我使用versions-maven-plugin 来更新项目版本。我想使用此更新版本安装工件,但 maven-install 插件使用旧版本。我必须如何配置项目以实现所描述的行为?
<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 生命周期,安装插件应该采用新版本,因为版本插件是在验证阶段执行的。
【问题讨论】:
-
versions-maven-plugin:set 目标仅用于从命令行运行,而不是在生命周期内......这永远不会起作用,因为 versions-maven-plugin:set 目标会改变pom.xml 文件,但在运行期间 pom.xml 已经加载到内存中,因此您将始终安装旧版本。你使用哪个 Maven 版本?
-
您好,谢谢您的回答,我使用的是 Maven 3.3.x。从命令行使用版本插件后,它起作用了!也许有人有相同的用例: build-helper:parse-version versions:set -DnewVersion=${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-${SVN_REVISION}
标签: maven maven-install-plugin