aleksandr-m / gitflow-maven-plugin

The Git-Flow Maven Plugin supports various Git workflows, including GitFlow and GitHub Flow. This plugin runs Git and Maven commands from the command line.
https://aleksandr-m.github.io/gitflow-maven-plugin/
Apache License 2.0
493 stars 181 forks source link

Add useReleaseProfile parameter for release, release-finish, hotfix-finish goals #231

Closed stefanseifert closed 4 years ago

stefanseifert commented 4 years ago

I'm in process of migrating from jgitflow-maven-plugin to gitflow-maven-plugin and i'm missing a useReleaseProfile parameter, here is the documentation from jgitflow-maven-plugin: https://bitbucket.org/atlassian/jgit-flow/wiki/goals/release-finish#!usereleaseprofile

currently gitflow-maven-plugin ignores maven profiles, but the release-profile profile is used by default by maven-release-plugin and jgitflow-maven-plugin and this should also be done by gitflow-maven-plugin (or at least optionally using a new flag to not break backward compatibility).


i figured out the following workaround to achieve this, but the configuration is quite clumsy:

<plugin>
  <groupId>com.amashchenko.maven.plugin</groupId>
  <artifactId>gitflow-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>default-cli</id>
      <goals>
        <goal>release</goal>
        <goal>release-finish</goal>
        <goal>hotfix-finish</goal>
      </goals>
      <configuration>
        <!-- Make sure release-profile gets activated, and pass through optional additional arguments (use same param name as maven-release-plugin) -->
        <argLine>-DperformRelease=true ${arguments}</argLine>
      </configuration>
    </execution>
  </executions>
</plugin>

with this it's possible to pass additional parameters when doing the release e.g. for code signing (same as for maven-release-plugin):

mvn -Darguments="-Dgpg.keyname=XXX-Dgpg.passphraseServerId=XXX" gitflow:release
aleksandr-m commented 4 years ago

It is deprecated.

You can also pass additional parameters using argLine from the command line.

stefanseifert commented 4 years ago

oh, i see, thanks for the pointer (see also [MRELEASE-896|https://issues.apache.org/jira/browse/MRELEASE-896]).

but that does not mean release profiles should not be used, it only means there is no predefined release profile any longer. there should be a easy support in gitflow-maven-plugin to activate one or multiple profile only for the release-relevant goals release, release-finish, hotfix-finish

the maven release plugin has a new (non-deprecated) property releaseProfiles for this: https://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html#releaseProfiles maybe such a property should be added

argLine is an alternative, but it is applied to all goals, not only the release-relevant goals. alternative would be to add something like postReleaseArgLine.

stefanseifert commented 4 years ago

as a fact it's already possible to (mis?)use the existing parameter postReleaseGoals for activating a release profile, example:

<gitflow.postReleaseGoals>clean deploy -Prelease-profile</gitflow.postReleaseGoals>

although the parameter is named "goals" it's string is passed without further processing to the command line of the additional maven call working exactly as intended.