我找不到在release:prepare
和release:perform
(两个)目标上激活某些Maven个人资料的解决方案。像这样:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<useReleaseProfile>false</useReleaseProfile>
<goals>deploy</goals>
<arguments>-Pmy-release</arguments>
</configuration>
</plugin>
只是不起作用。我知道releaseProfiles
设置仅在release:perform
期间有效,所以我只是arguments
设置正是我想要的,但my-profile
配置文件在执行期间无效。我做错了吗?
答案 0 :(得分:7)
这看起来像一个重复的问题。请看一下这个问题,它有一个答案。 maven release plugin ignores releaseProfile
基本上版本2.2.1版本添加了一个releaseProfiles
参数,允许您定义要在发布期间启用的配置文件。
http://maven.apache.org/plugins/maven-release-plugin/examples/perform-release.html
不幸的是,看起来有一个错误会阻止它做你想做的事情......
修改强>
我在这种情况下使用的一件事是不使用-P
参数,而是使用-Denv=release
通过环境设置触发配置文件。然后在POM中,我根据env
的值激活配置文件。这一直对我有用。
答案 1 :(得分:6)
因为maven release插件启动了额外的实例,所以你必须指定其他参数。对于你的情况
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.4</version>
<configuration>
<arguments>${myReleaseArgs}</arguments>
</configuration>
</plugin>
和执行
mvn release:prepare release:perform -DmyReleaseArgs="-Pmy-release -DskipTests=true" -Pmy-release -DskipTests=true
是的,必须重复。
答案 2 :(得分:6)
-Darguments =“ - PmyProfile”似乎可以胜任。
答案 3 :(得分:2)
它通过激活两个版本的配置文件在Jenkins中起作用:准备和释放:通过设置两个属性来执行
<build>
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<releaseProfiles>myprofile</releaseProfiles>
<arguments>-Pmyprofile</arguments>
</configuration>
</plugin>
</plugins>
</build >
即使上述工作很好,我发现使用文件激活的配置文件更有用。具有“主”配置文件的旧概念导致了问题,因为我在父pom中有配置文件。这意味着,它在每个模块中被激活,是任意的。
为了解决这个问题,我在配置文件中使用了文件激活方法。它工作得更好,作为奖励,它简化了詹金斯的发布。在Eclipse中,在命令行中,在Jenkins,也就是所有地方,maven检测文件并且不必配置maven-release-plugin。此外,配置文件仅在正确的模块中处于活动状态。