Activate profile when finishing release using jgitflow Maven plugin?

957 Views Asked by At

I have a Maven profile documentation that I want to get activated when running mvn jgitflow:release-finish. I know that I can do:

mvn jgitflow:release-finish -Pdocumentation

because the documentation of the plugin states:

automatically copies any profiles (-P) and user-properties (-D) passed on the command line to the forked maven process when building

But that means that you cannot forget to add this profile manually.

Objective: I would like to be able to configure Maven so that this profile becomes active automatically (Or that I somehow can activate my profile when the 'release' profile is active).

1

There are 1 best solutions below

1
On BEST ANSWER

The jgitflow:release-finish goal actually uses a default option useReleaseProfile defining:

Whether to use the release profile that adds sources and javadocs to the released artifact, if appropriate. If set to true, the plugin sets the property performRelease to true, which activates the profile "release-profile", which is inherited from the super pom.

This option has default value to true, hence when executing this goal will by default set the performRelease property to true.

Note that the release profile mentioned above is defined by the super POM, which is actually used by this plugin but also by the maven-release-plugin via the similar useReleaseProfile option.

You can then activate your profile based on this option as well, as following:

<profiles>
  <profile>
    <id>documentation</id>
    <activation>
      <property>
        <name>performRelease</name>
        <value>true</value>
      </property>
    </activation>
    ...
  </profile>
</profiles>

This means that you can still esplicitely activate it via the -P option and that it will be automatically activated by the goal as well.