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

Option to commit files which are changed during the release build #222

Open cobaasta opened 4 years ago

cobaasta commented 4 years ago

Great Plugin - I like the possibility to add custom maven goals. Unfortunately the current possibilities do not exactly match my needs.

The background: We build Angular Frontends and Node.js Libraries with com.github.eirslett.frontend-maven-plugin, which executes npm commands during a Maven build. For Release builds they need the correct version to be set in the package.json file, and a npm publish can be done. During the process-resources phase the version ist set to the package.json file with the npm version command.

The problem: The gitflow plugin is updating the version in the pom.xml files of the release branch at the beginning of release-start, prior to the build itself. The maven build (mvn packge) then adopts the version in the package.json file. The gitflow:relese-finish then throws an error: [ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.14.0:release-finish (default-cli) on project jee-starter: release-finish: You have some uncommitted files. Commit or discard local changes in order to proceed.

Possible soulutions:

This is my plugin configuration in parent pom.xml:

        <plugin>
            <groupId>com.amashchenko.maven.plugin</groupId>
            <artifactId>gitflow-maven-plugin</artifactId>
            <version>${gitflow-maven-plugin.version}</version>
            <configuration>
                <verbose>true</verbose>
                <!-- Whether to call Maven install goal during the mojo execution.
                     Avoid this, otherwise the following error occurs: You have some uncommitted files. -->
                <installProject>false</installProject>
                <!-- Maven goals to execute in the release branch before merging into the production branch.
                     Do a git commit for the during release-finish changed version in package.json.
                     Otherwise the following error occurs: You have some uncommitted files. -->
                <preReleaseGoals>-Dmessage="Set release version to package.json" scm:checkin</preReleaseGoals>
                <!-- Maven goals to execute in the production branch after the release.
                     Do a maven deploy for deploying the artifacts to nexus. -->
                <postReleaseGoals>deploy</postReleaseGoals>
                <commitMessages>
                    <releaseStartMessage>Update versions for release @{version}</releaseStartMessage>
                    <releaseVersionUpdateMessage>Update for next development version @{version}</releaseVersionUpdateMessage>
                    <releaseFinishMessage>Update for next development version @{version}</releaseFinishMessage>
                    <tagReleaseMessage>Tag release ${project.version}</tagReleaseMessage>
                </commitMessages>
            </configuration>
        </plugin>
aleksandr-m commented 4 years ago

If you are using scm plugin then how about just executing something like mvn -B gitflow:release-start scm:checkin gitflow:release-finish.