Maven发布插件忽略releaseProfile [英] maven release plugin ignores releaseProfile

查看:350
本文介绍了Maven发布插件忽略releaseProfile的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用两个配置文件:开发和生产.

I am using two profiles: development and production.

默认情况下,开发应该处于活动状态;发布时应该使用生产.

Development should be active on default; production should be used when I am releasing.

在我的pom.xml中,我有:

In my pom.xml I have:

[...]
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.0-beta-9</version>
<configuration>
  <useReleaseProfile>false</useReleaseProfile>
  <goals>deploy</goals>
  <arguments>-Pproduction</arguments>
</configuration>
</plugin>
[...]
<profiles>
  <profile>
    <id>production</id>
    <properties>
      <profile.name>production</profile.name>
    </properties>
    [...]
  </profile>
  <profile>
    <id>development</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
    <profile.name>development</profile.name>
    </properties>
       [...]
  </profile>
[...]

那是行不通的.
useReleaseProfiles也不起作用: http://jira.codehaus.org/browse/MRELEASE-459

It just does not work.
useReleaseProfiles doesn't work either: http://jira.codehaus.org/browse/MRELEASE-459

开发配置文件应始终处于活动状态,但在运行mvn release:perform时不应处于活动状态. 您如何实现的?

The development profile should be always active but not when running mvn release:perform. How do you achieve this?

[更新]: 我已经在debug标志中看到使用了我的生产配置文件,但是也使用了开发配置文件,因为它是activeByDefault.不能被releaseProfile参数覆盖.最好强制发布插件仅使用 生产"配置文件.

[UPDATE]: I have seen with the debug flag that my production profile is used, but development profile is used too, because it is activeByDefault. This cant be overridden by the releaseProfile argument. It would be nice to force the release plugin to use only the "production" profile.

推荐答案

maven-release-plugin

The maven-release-plugin documentation encourages using the releaseProfiles configuration parameter to automatically invoke profiles during the release process.

与从命令行手动调用发布配置文件相比,这是一种更好的方法.原因之一是因为该发行版中使用的配置文件将记录在pom.xml中,并与标记的代码一起存储.这使构建过程更易于理解,以后也易于重复,与项目最初发布的方式完全相同.

This is a better approach than manually invoking release profiles from the command-line. One reason, is because the profiles used in the release will be documented in the pom.xml and stored with the tagged code. This makes the build process easier to understand and easier to repeat later, exactly the same way the project was originally released.

如果使用早于2.4maven-release-plugin,请参见此错误阻止使用上述参数.

If using maven-release-plugin older than 2.4 see this bug preventing use of the above mentioned parameter.

请注意,在多模块项目的情况下,必须将"releaseProfiles"配置放入root pom!另请参阅此问题,以获取有关此问题的更多信息.

Be aware that in case of a multi-module project you'll have to put the "releaseProfiles" configuration in the root pom! See also this issue for more information about that.

这篇关于Maven发布插件忽略releaseProfile的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆