问题描述
我正在使用两个配置文件:开发和生产.
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
文档鼓励在发布过程中使用releaseProfiles
配置参数自动调用配置文件.
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.4
的maven-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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!