开发者

maven release plugin ignores releaseProfile

I am using two profiles: development and production.

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

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>
[...]

It just does not work.

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

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

[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.


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

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.

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

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.


I think you should simply activate your profiles through a property.

<profiles>
  <profile>
    <id>production</id>
    <activation>
      <property>
        <name>build</name>
        <value>release</value>
      </property>
    </activation>
    [...]
  </profile>
  <profile>
    <id>development</id>
    <activation>
      <property>
        <name>build</name>
        <value>develop</value>
      </property>
    </activation>
    [...]
  </profile>
<profiles>

Do your builds by executing something like this

mvn -Dbuild=develop package
mvn -Dbuild=develop test

mvn -Dbuild=release release:prepare
mvn -Dbuild=release release:perform


If you check "Introduction to Build Profiles", "Deactivating a profile":

mvn groupId:artifactId:goal -P !profile-1,!profile-2

I guess you could use this to deactivate your default profile?


This is a very old post but I came across this issue quite recently. The releaseProfile only worked for me when I set the releaseProfiles to profile called release. Any other profile gives same error.

Sample code:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <tagNameFormat>@{project.artifactId}-@{project.version}</tagNameFormat>
                <autoVersionSubmodules>true</autoVersionSubmodules>
                <releaseProfiles>release</releaseProfiles>
                <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
            </configuration>
        </plugin>
    </plugins>
</build>
<profiles>
    <profile>
        <id>release</id>
        <properties>
            <connectionUrl>${scm-base}/tags/${project.artifactId}-${project.version}</connectionUrl>
        </properties>
    </profile>
</profiles>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜