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
494 stars 182 forks source link

Different argLine for various branches (Production, Development, ...) to fully support maven-ci-friendly-versions #314

Open mmusenbr opened 3 years ago

mmusenbr commented 3 years ago

Hi, first of all, thanks for the awesome work on this plugin.

We currently use gitflow-maven-plugin via CI to perform our hotfix and release start/finish tasks. We switched to use Maven CI friendly versioning, and also use it for our dependencies. This raises the need to set the changelist-property to empty for builds done on master/release, but NOT change it for builds on development branches, to make sure the correct dependencies (released/snapshot) are used. Info: our provided maven repository cleans -SNAPSHOT builds, once a release build exists.

Would there be a need/want to support this? If yes, I may have time to support with an MR (after details are clarified of course).

regards m

aleksandr-m commented 3 years ago

@redeamer See discussion in #305. Why do you use separate property for holding -SNAPSHOT? PR-s are welcome. :)

mmusenbr commented 3 years ago

Hi @aleksandr-m, thanks for the quick response. Because #305 does not cover the case, that dependency versions are also using the <changelist>-property. Like in the Maven CI Friendly Multi Module Dependencies Example. Whe have the case that we have multiple modules, having the version number streamlined over the modules.

Let's take the following pom.xml in a hotfix 1.3.1 branch:

<version>${revision}${changelist}</version>
<properties>
  <revision>1.3.1</revision>
  <changelist>-SNAPSHOT</changelist>
</properties>

<dependencyManagement>
  <dependencies>
    <dependency>
      ...
      <artifactId>dep1</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>
</dependencyManagement>

Now let's assume the following revisions in the branches:

On hotfix-finish the hotfix, master and development branch is checked out. When the hotfix and master branch is checked out and a mvn command is performed, we would need changelist='' passed, that dep1 is pulled without the -SNAPSHOT, because 1.3.0-SNAPSHOT does not exist anymore. But if dev is checked out and a mvn command is issued, we would need to have changelist not changed, to get 1.4.0-SNAPSHOT, because 1.4.0 does not exist yet.

Therefore we would need to support argLine per branch-type, to cover our use-case. I was thinking about a productionArgLine, developmentArgLine, hotfixArgLine, ....

mmusenbr commented 3 years ago

While writing the previous comment I was also looking into the plugin's code, and we run into the issue does not happen in the mvnXXX-commands, but already in the getCurrentProjectVersion-calls. I would need to have a look, if we can avoid the fetching of the deps for those calls. Then it should work (as far as I can see it from the code).

aleksandr-m commented 3 years ago

@redeamer Why there is need to use separate changelist property at all? Can't you just add -SNAPSHOT to revision?

mmusenbr commented 3 years ago

@aleksandr-m sorry for my late response, but I was off last week. This is what we did before, but we streamlined all our projects to use Maven CI friendly versioning with the use of revision and changelist for all our projects. So this is unfortunately a settled decision. Otherwise we would switch to do it 'manually'. I created a local version of the plugin which supports the options changelistProperty (to override 'changelist' as default), and the values via productionChangelistValue, developmentChangelistValue, ... which would add support for the variable changelist-property, but I am not entirely happy with my current solution, because it messes with the Properties and the argLine to change the values per branch. If you are generally interested in support of branch based changelist (and maybe sha1 for completeness) I would created MR with the current solution, to have a base to talk.

mmusenbr commented 3 years ago

@aleksandr-m Opened a PR #315

simontunnat commented 2 years ago

Is there anything I could do to help getting this feature merged? :)