active a profile during release prepare in maven 3 does not work
I have a need to active a profile during release:prepare.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<arguments>-Prelease</arguments>
<preparationGoals>clean validate</preparationGoals>
<goals>test-compile</goals>
</configuration>
</plugin>
</plugin>
</build>
But when I run:
mvn release:prepare -开发者_如何学JAVADdryRun=true help:active-profiles
it never show profile release in active list. and it is not show up on active profile list when I do:
mvn release:perform help:active-profiles
I could not not use <releaseProfiles>
since I want this profile to be used in both prepare and perform
Thanks!
One thing that I have used in this case is not using the -P argument, but rather triggering the profile through an environment setting using -Denv=release. Then in the POM, I have the profile activation based on the value of env. This has always worked for me. So in the arguments
parameter, you could put something like
<arguments>-Denv=release</arguments>
Similar questions can be found here:
- Profile activation on both release:prepare and release:perform
- maven release plugin ignores releaseProfile
I think there's some misunderstanding here: mvn release:prepare -DdryRun=true help:active-profiles
will never show the active profiles used during the release, but it shows the current active profiles. release:prepare
will start another Maven thread (separate executable), and only then the release profile is activated.
In the maven-release-plugin-2.4 a lot has been fixed with regards to profiles, especially for Maven3, since some information was not available anymore when using Maven 2 but now is with Maven 3. See the release notes
精彩评论