Active profile during release is prepared in maven 3 does not work

I have a need to activate 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 -DdryRun=true help:active-profiles 

it never shows the profile release in the active list. and this does not appear in the list of active profiles when I do:

 mvn release:perform help:active-profiles 

I could not help using <releaseProfiles> because I want this profile to be used for both preparation and execution.

Thanks!

+4
source share
2 answers

I think there are some misunderstandings here: mvn release:prepare -DdryRun=true help:active-profiles will never show the active profiles used during release, but it will show the currently active profiles. release:prepare will launch another Maven thread (separate executable), and only then will the release profile be activated.

In maven-release-plugin-2.4, a lot has been fixed with respect to profiles, especially for Maven3, as some information was no longer available when using Maven 2, but now with Maven 3. See release notes

+1
source

One thing that I used in this case does not use the -P argument, but rather launches the profile through setting the environment using -Denv = release. Then in POM I have a profile activation based on env value. It always worked for me. So in the arguments parameter you can add something like

 <arguments>-Denv=release</arguments> 

Similar questions can be found here:

0
source

Source: https://habr.com/ru/post/1348140/


All Articles