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
488 stars 180 forks source link

New merge behavior causes issues when sub-modules where added to the develop branch #345

Closed simontunnat closed 2 years ago

simontunnat commented 2 years ago

The new merge behavior introduced with plugin version 1.18.0 causes issues in the following case:

  1. A release or hotfix branch has been created
  2. New sub-modules where added in the develop branch ("ui.config/local.author65" and "ui.config/local.publish65")
  3. We try to finalize the release or hotfix
[ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.18.0:hotfix-finish (default-cli) on project PROJECT: hotfix-finish: Error re-loading project info: Some problems were encountered while processing the POMs:
[ERROR] [ERROR] 'dependencies.dependency.version' for com.COMPANY:PROJECT.ui.config.local.author65:zip is missing. @ com.COMPANY:PROJECT.all:${revision}, /home/USER/PROJECT/all/pom.xml, line 269, column 21
[ERROR] [ERROR] 'dependencies.dependency.version' for com.COMPANY:PROJECT.ui.config.local.publish65:zip is missing. @ com.COMPANY:PROJECT.all:${revision}, /home/USER/PROJECT/all/pom.xml, line 274, column 21
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.18.0:hotfix-finish (default-cli) on project PROJECT: hotfix-finish
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: hotfix-finish
    at com.amashchenko.maven.plugin.gitflow.GitFlowHotfixFinishMojo.execute (GitFlowHotfixFinishMojo.java:383)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: Error re-loading project info
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.reloadProject (AbstractGitFl

The issue here seems to be that the plugin has checked out branch "release/22.4.0" but does not correctly reload the project info.

The problem does not occur if we set the "noBackMerge" and "noBackMergeHotfix" parameters or if we downgrade to version 1.17.0.

I could try to create a minimal test case for this if you need this to reproduce the error.

simontunnat commented 2 years ago

I had a hard time creating a minimal integration test for this. :/ I will inspect further as this might have something to do with one of the other plugins we are using.

aleksandr-m commented 2 years ago

Not clear. How development branch changes are related to hotfix? How project reloading is related to merging?

wumpz commented 2 years ago

Same exceptions here after upgrading to version 1.18.

beatngu13 commented 2 years ago

This might has to do with #324? At least "Error re-loading project info" indicates that.

Unfortunately, the stack trace stops there. Could add the full stack trace?

aleksandr-m commented 2 years ago

@wumpz Which exception? Can you be more specific. Steps to reproduce?

wumpz commented 2 years ago

Sorry. Typo. Same error for missing version information. I guess those versions ar defined in the roots dependency management section

simontunnat commented 2 years ago

Here the full stracktrace:

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for org.tunnat.maven:gitflow-ci-new-merge-behaviour-issue-example 1.1-SNAPSHOT:
[INFO] 
[INFO] org.tunnat.maven:gitflow-ci-new-merge-behaviour-issue-example FAILURE [  0.343 s]
[INFO] module-a ........................................... SUCCESS [  0.002 s]
[INFO] module-b ........................................... SUCCESS [  0.001 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.538 s
[INFO] Finished at: 2022-05-02T06:51:25+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.18.0:release-finish (default-cli) on project gitflow-ci-new-merge-behaviour-issue-example: release-finish: Error re-loading project info: Some problems were encountered while processing the POMs:
[ERROR] [FATAL] Non-readable POM /home/simon/Workspace/github/simontunnat/maven-gitflow-ci-new-merge-behaviour-issue-example/module-b/pom.xml: /home/simon/Workspace/github/simontunnat/maven-gitflow-ci-new-merge-behaviour-issue-example/module-b/pom.xml (No such file or directory) @
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.18.0:release-finish (default-cli) on project gitflow-ci-new-merge-behaviour-issue-example: release-finish
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:577)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: release-finish
    at com.amashchenko.maven.plugin.gitflow.GitFlowReleaseFinishMojo.execute (GitFlowReleaseFinishMojo.java:392)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:577)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.MojoFailureException: Error re-loading project info
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.reloadProject (AbstractGitFlowMojo.java:361)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.checkSnapshotDependencies (AbstractGitFlowMojo.java:401)
    at com.amashchenko.maven.plugin.gitflow.GitFlowReleaseFinishMojo.execute (GitFlowReleaseFinishMojo.java:224)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:577)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-readable POM /home/simon/Workspace/github/simontunnat/maven-gitflow-ci-new-merge-behaviour-issue-example/module-b/pom.xml: /home/simon/Workspace/github/simontunnat/maven-gitflow-ci-new-merge-behaviour-issue-example/module-b/pom.xml (No such file or directory) @ 

    at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:397)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.reloadProject (AbstractGitFlowMojo.java:348)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.checkSnapshotDependencies (AbstractGitFlowMojo.java:401)
    at com.amashchenko.maven.plugin.gitflow.GitFlowReleaseFinishMojo.execute (GitFlowReleaseFinishMojo.java:224)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:972)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke (DirectMethodHandleAccessor.java:104)
    at java.lang.reflect.Method.invoke (Method.java:577)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

I also built a minimal example repository for the issue: https://github.com/simontunnat/maven-gitflow-ci-new-merge-behaviour-issue-example (Checkout the develop branch and execute the command mvn clean gitflow:release-finish -B -DcommitDevelopmentVersionAtStart -DuseSnapshotInRelease -DpushRemote=false)

simontunnat commented 2 years ago

I think the issue is that Maven for some reason tries to evaluate the sub-module "module-b" when the release branch is checked out, even though the sub-module only exists in the "develop" branch.

This loop here gets all projects and these already include "module-b". :( https://github.com/aleksandr-m/gitflow-maven-plugin/blob/500151ee33e671e38ad662c7fdc10860b9d610b1/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java#L400

simontunnat commented 2 years ago

It seems by example project also fails with the release-finish goal with version 1.17.0. My initial problem did only occur with version 1.18.0.

aleksandr-m commented 2 years ago

@simontunnat Thanks for the repro.

It is not about merge behavior. It is about checking for SNAPSHOT dependencies with the new project reloading. We need to obtain projects the same way as the current project, and then there is no need to reload project in the loop.

aleksandr-m commented 1 year ago

1.19.0 is released.