Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version in the ${revision} and "-SNAPSHOT" suffix in the ${changelist} property #305

Closed
simontunnat opened this issue Jul 18, 2021 · 13 comments

Comments

@simontunnat
Copy link

simontunnat commented Jul 18, 2021

I have the following feature request:

I'm using the Maven CI-friendly versions (https://maven.apache.org/maven-ci-friendly.html) that where implemented in the Gitflow Maven plugin as part of the ticket #151.

My POM looks like this:

<version>${revision}${changelist}</version>

<properties>
  <revision>1.0</revision>
  <changelist>-SNAPSHOT</changelist>
</properties>

What I would like the plugin to do:

  • Increment the revision parameter (e.g. to 1.1)
  • Do not add -SNAPSHOT to the parameter value

If I want to build a SNAPSHOT or RELEASE version would then be completely left to me, by doing something like this:
mvn -Dchangelist= clean verify

I could also use my CI system to do something like this:
mvn -Dchangelist="-20210718.191300" clean verify

A similar approach worked very well for me in the past and I would like to use it with the Gitflow Maven plugin.

If a PR for this might have some chances to be accepted, I could try to implement it myself (did not have look at the code base jet).

@aleksandr-m
Copy link
Owner

You can pass additional arguments to mvn goals using argLine parameter, e.g. -DargLine="-Dchangelist=".

@simontunnat
Copy link
Author

Thank you, but that does not solve my problem.

If the value of revision is 1.0 before the release, it will become 1.1-SNAPSHOT after the release. I need an option to force the Gitflow plugin to NOT add the -SNAPSHOT suffix.

@aleksandr-m
Copy link
Owner

Yes, -DargLine="-Dchangelist=" will set changelist property to empty string in underlying maven commands. Try it out.

@aleksandr-m
Copy link
Owner

Should be supported. Feel free to reopen if something is missing.

@simontunnat
Copy link
Author

Maybe I was not clear enough before:
I use the automatic version numbering of the gitflow plugin. Tgat featire always adds the "-SNAPSHOT" suffix to the new development version. I nedd a way to disable this behaviour.

@aleksandr-m
Copy link
Owner

@simontunnat Which command you are running?

@simontunnat
Copy link
Author

simontunnat commented Aug 4, 2021

Example:

$ mvn gitflow:release-start -B

[INFO] Scanning for projects...
[INFO] 
[INFO] -------< org.tunnat.maven:gitflow-ci-friendly-versions-example >--------
[INFO] Building org.tunnat.maven:gitflow-ci-friendly-versions-example 1.4-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- gitflow-maven-plugin:1.16.0:release-start (default-cli) @ gitflow-ci-friendly-versions-example ---
[INFO] Checking for uncommitted changes.
[INFO] Fetching remote branch 'origin develop'.
[INFO] Comparing local branch 'develop' with remote 'origin/develop'.
[INFO] Checking out 'develop' branch.
[INFO] Checking for SNAPSHOT versions in dependencies.
[INFO] Version is blank. Using default version.
[INFO] Creating a new branch 'release/1.4' from 'develop'.
[INFO] Updating version(s) to '1.5-SNAPSHOT'.
[INFO] Updating property 'revision' to '1.5-SNAPSHOT'.
[INFO] Committing changes.
[INFO] Checking out 'release/1.4' branch.
[INFO] Pushing 'develop' branch to 'origin'.
[INFO] Pushing 'release/1.4' branch to 'origin'.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.845 s
[INFO] Finished at: 2021-08-04T11:06:55+02:00
[INFO] ------------------------------------------------------------------------

POM before command execution:

  <properties>
    <revision>1.4</revision>
    <changelist>-SNAPSHOT</changelist>
  </properties>

POM after command execution:

  <properties>
    <revision>1.5-SNAPSHOT</revision>
    <changelist>-SNAPSHOT</changelist>
  </properties>

The plugin is configured like this:

  <build>
    <plugins>
      <plugin>
        <groupId>com.amashchenko.maven.plugin</groupId>
        <artifactId>gitflow-maven-plugin</artifactId>
        <version>1.16.0</version>
        <configuration>
          <pushRemote>true</pushRemote>
          <versionProperty>revision</versionProperty>
          <skipUpdateVersion>true</skipUpdateVersion>
          <commitDevelopmentVersionAtStart>true</commitDevelopmentVersionAtStart>
          <digitsOnlyDevVersion>true</digitsOnlyDevVersion>
          <useSnapshotInRelease>true</useSnapshotInRelease>
          <preReleaseGoals>verify</preReleaseGoals>
          <postReleaseGoals>verify</postReleaseGoals>

          <gitFlowConfig>
            <productionBranch>main</productionBranch>
            <versionTagPrefix>v</versionTagPrefix>
          </gitFlowConfig>
        </configuration>
      </plugin>
    </plugins>
  </build>

The same thing happens when I execute the command with the argLine parameter:

$ mvn gitflow:release-start -B -DargLine="-Dchangelist="

[INFO] Scanning for projects...
[INFO] 
[INFO] -------< org.tunnat.maven:gitflow-ci-friendly-versions-example >--------
[INFO] Building org.tunnat.maven:gitflow-ci-friendly-versions-example 1.4-SNAPSHOT
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- gitflow-maven-plugin:1.16.0:release-start (default-cli) @ gitflow-ci-friendly-versions-example ---
[INFO] Checking for uncommitted changes.
[INFO] Fetching remote branch 'origin develop'.
[INFO] Comparing local branch 'develop' with remote 'origin/develop'.
[INFO] Checking out 'develop' branch.
[INFO] Checking for SNAPSHOT versions in dependencies.
[INFO] Version is blank. Using default version.
[INFO] Creating a new branch 'release/1.4' from 'develop'.
[INFO] Updating version(s) to '1.5-SNAPSHOT'.
[INFO] Updating property 'revision' to '1.5-SNAPSHOT'.
[INFO] Committing changes.
[INFO] Checking out 'release/1.4' branch.
[INFO] Pushing 'develop' branch to 'origin'.
[INFO] Pushing 'release/1.4' branch to 'origin'.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.878 s
[INFO] Finished at: 2021-08-04T11:11:49+02:00
[INFO] ------------------------------------------------------------------------

Setting the changelist parameter directly does not work as well:

$ mvn gitflow:release-start -B -DargLine="-Dchangelist=" -Dchangelist=

[INFO] Scanning for projects...
[INFO] 
[INFO] -------< org.tunnat.maven:gitflow-ci-friendly-versions-example >--------
[INFO] Building org.tunnat.maven:gitflow-ci-friendly-versions-example 1.4
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- gitflow-maven-plugin:1.16.0:release-start (default-cli) @ gitflow-ci-friendly-versions-example ---
[INFO] Checking for uncommitted changes.
[INFO] Fetching remote branch 'origin develop'.
[INFO] Comparing local branch 'develop' with remote 'origin/develop'.
[INFO] Checking out 'develop' branch.
[INFO] Checking for SNAPSHOT versions in dependencies.
[INFO] Version is blank. Using default version.
[INFO] Updating version(s) to '1.4-SNAPSHOT'.
[INFO] Updating property 'revision' to '1.4-SNAPSHOT'.
[INFO] Committing changes.
[INFO] Creating a new branch 'release/1.4' from 'develop'.
[INFO] Updating version(s) to '1.5-SNAPSHOT'.
[INFO] Updating property 'revision' to '1.5-SNAPSHOT'.
[INFO] Committing changes.
[INFO] Checking out 'release/1.4' branch.
[INFO] Pushing 'develop' branch to 'origin'.
[INFO] Pushing 'release/1.4' branch to 'origin'.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.106 s
[INFO] Finished at: 2021-08-04T11:15:19+02:00
[INFO] ------------------------------------------------------------------------

I hope this finally make my issue clear. :)

@aleksandr-m
Copy link
Owner

@simontunnat Set useSnapshotInRelease to false or don't use it at all - the default is false.

@simontunnat
Copy link
Author

The plugin always behaves the same way: Even with useSnapshotInRelease set to false the next development version will be suffixed with -SNAPSHOT.

I'm bot sure what else I can do to make my issue clear. :(

@aleksandr-m
Copy link
Owner

Where did you set it? You need to set in the pom, since you have useSnapshotInRelease there.

When you say "next development version", what do you mean by that? Version in the revision property? After the release start or finish?

@simontunnat
Copy link
Author

I mean the next version in the develop branch after the release finish or directly after the release start if I use the commitDevelopmentVersionAtStart feature.

@aleksandr-m
Copy link
Owner

Well, you can try to use digitsOnlyDevVersion which will strip any qualifiers from the version.

@simontunnat
Copy link
Author

I'm already using that property, but it did not change the behaviour regarding the next development version.

A quick look into the code made it clear to me that changes would have to be made.

Would you be willing to accept an PR regarding this issue? I'm thinking of an additional property useSnapshotInDevVersion. This property would be set to true by default and the plugin would then behave in the same way it does now. But if the property is set to false the plugin would remove the -SNAPSHOT suffix.

mmusenbr added a commit to mmusenbr/gitflow-maven-plugin that referenced this issue Oct 15, 2021
mmusenbr added a commit to mmusenbr/gitflow-maven-plugin that referenced this issue Oct 15, 2021
mmusenbr added a commit to mmusenbr/gitflow-maven-plugin that referenced this issue Oct 15, 2021
mmusenbr added a commit to mmusenbr/gitflow-maven-plugin that referenced this issue Oct 15, 2021
mmusenbr added a commit to mmusenbr/gitflow-maven-plugin that referenced this issue Dec 23, 2021
mmusenbr added a commit to mmusenbr/gitflow-maven-plugin that referenced this issue Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants