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

hotfix-finish fails in Multi Maven Project if a new dependency was previously added to the develop branch #412

Open
DManstrator opened this issue Oct 4, 2024 · 1 comment

Comments

@DManstrator
Copy link

Hello.

I stumbled upon a weird bug where the hotfix-finish goal is failing under special circumstances.

  1. The project is a Multi Maven Project (has a Parent POM and Module POMs).
  2. A completely new dependency was added to the develop branch between the last release and the upcoming hotfix release.

The concrete error is that the build fails with 'dependencies.dependency.version' for <dependency> is missing. However, the version is set properly (only in the dependency in the Parent POM).

The exact location where this is failing is after merging the hotfix branch into the master branch, creating the tag, checking out the develop branch und updating the version. After the version update, it will be attempted to update the value of project.build.outputTimestamp. Here the error occurrs (I was able to verify this by setting updateOutputTimestamp to false, then the build succeeded).

My guess is that some kind of race condition in combination with a version clash happens. The dependency is available in the develop branch (e.g. 1.0.1-SNAPSHOT). On the hotfix branch (e.g. 1.0.1), this dependency is not available (yet). When updating the version of the develop branch to the hotfix version, there are now two different states of the same version, one with and one without the dependency. And somehow Maven thinks that the version is missing (since it's only defined in the Parent POM).

I was able to reproduce this in two different projects with two different dependencies, only having the Multi Maven Project and the newly added dependency in common.

Steps to reproduce:

  1. Having a Multi Maven Project with a develop and a master branch (a simple project with one module should be enough).
  2. Ensure the develop branch is on a different version than the master branch (e.g. 1.0.1-SNAPSHOT for develop and 1.0.0 for master).
  3. Add a new dependency to the project.
    1. Add the dependency with a version to the dependencyManagement block of the Parent POM.
    2. Add the dependency without the version to the dependencies block of the Module POM.
  4. Start a hotfix release.
  5. Finish the hotfix release.

My plugin configuration:

<plugin>
    <groupId>com.amashchenko.maven.plugin</groupId>
    <artifactId>gitflow-maven-plugin</artifactId>
    <version>1.21.0</version>
    <configuration>
        <argLine>-DskipTests</argLine>
        <installProject>true</installProject>
        <skipTestProject>true</skipTestProject>
        <postReleaseGoals>deploy</postReleaseGoals>
        <pushRemote>true</pushRemote>
        <verbose>true</verbose>
    </configuration>
</plugin>

Commands executed:

  • mvn -B gitflow:hotfix-start -DhotfixVersion=$RELEASE_VERSION
  • mvn -B gitflow:hotfix-finish -DhotfixBranch=$CI_COMMIT_BRANCH

Logs:

Logs
$ git symbolic-ref refs/heads/$CI_COMMIT_REF_NAME refs/remotes/origin/$CI_COMMIT_REF_NAME
$ mvn -B gitflow:hotfix-finish -DhotfixBranch=$CI_COMMIT_BRANCH
681 [INFO] Error stacktraces are turned on.
714 [INFO] Scanning for projects...
763 [INFO] ------------------------------------------------------------------------
763 [INFO] Reactor Build Order:
763 [INFO] 
764 [INFO] <Project Name>                                                       [pom]
764 [INFO] <Module 1>                                                             [jar]
764 [INFO] <Module 2>                                                          [jar]
764 [INFO] <Module 3>                                                          [jar]
764 [INFO] <Module 4>                                                           [pom]
12971 [INFO] 
12971 [INFO] --------< <group>:<Parent Module> >---------
12971 [INFO] Building <Project Name> 8.0.1                                        [1/5]
12971 [INFO]   from pom.xml
12971 [INFO] --------------------------------[ pom ]---------------------------------
12978 [INFO] 
12979 [INFO] --- gitflow:1.21.0:hotfix-finish (default-cli) @ <Parent Module> ---
29255 [INFO] Checking for uncommitted changes.
29276 [INFO] Fetching remote from 'origin'.
"origin/hotfix/8.0.1"
29617 [INFO] Comparing local branch 'hotfix/8.0.1' with remote 'origin/hotfix/8.0.1'.
0	0
29626 [INFO] Fetching remote from 'origin'.
"origin/develop"
29923 [INFO] Local branch 'develop' doesn't exist. Trying check it out from 'origin'.
29923 [INFO] Creating a new branch 'develop' from 'origin/develop' and checking it out.
Branch 'develop' set up to track remote branch 'develop' from 'origin'.
29932 [WARNING] Previous HEAD position was d6d5c71 Update versions for hotfix
Switched to a new branch 'develop'
29932 [INFO] Fetching remote from 'origin'.
"origin/master"
30227 [INFO] Local branch 'master' doesn't exist. Trying check it out from 'origin'.
30227 [INFO] Creating a new branch 'master' from 'origin/master' and checking it out.
Branch 'master' set up to track remote branch 'master' from 'origin'.
30233 [WARNING] Switched to a new branch 'master'
30233 [INFO] Fetching remote from 'origin'.
30512 [INFO] Checking out 'hotfix/8.0.1' branch.
30517 [WARNING] Switched to branch 'hotfix/8.0.1'
30525 [INFO] Checking out 'master' branch.
Your branch is up to date with 'origin/master'.
30531 [WARNING] Switched to branch 'master'
30531 [INFO] Merging (--no-ff) 'hotfix/8.0.1' branch.
Merge made by the 'ort' strategy.
 <Folder 1>/pom.xml   | 2 +-
 <Folder 4>/pom.xml | 2 +-
 pom.xml          | 2 +-
 <Folder 3>/pom.xml     | 2 +-
 <Folder 2>/pom.xml     | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)
30546 [INFO] Creating '8.0.1' tag.
30554 [INFO] Checking out 'develop' branch.
Your branch is up to date with 'origin/develop'.
30559 [WARNING] Switched to branch 'develop'
30565 [INFO] Updating version(s) to '8.0.1'.
636 [INFO] Error stacktraces are turned on.
668 [INFO] Scanning for projects...
716 [INFO] ------------------------------------------------------------------------
716 [INFO] Reactor Build Order:
716 [INFO] 
717 [INFO] <Project Name>                                                       [pom]
717 [INFO] <Module 1>                                                             [jar]
717 [INFO] <Module 2>                                                          [jar]
717 [INFO] <Module 3>                                                          [jar]
717 [INFO] <Module 4>                                                           [pom]
2573 [INFO] 
2573 [INFO] --------< <group>:<Parent Module> >---------
2573 [INFO] Building <Project Name> 8.0.1-SNAPSHOT                               [1/5]
2573 [INFO]   from pom.xml
2573 [INFO] --------------------------------[ pom ]---------------------------------
2577 [INFO] 
2578 [INFO] --- versions:2.16.0:set (default-cli) @ <Parent Module> ---
25958 [INFO] Searching for local aggregator root...
25958 [INFO] Local aggregation root: /builds/<Project Folder>
25961 [INFO] Processing change of <group>:<Parent Module>:8.0.1-SNAPSHOT -> 8.0.1
25993 [INFO] Processing <group>:<Parent Module>
25994 [INFO]     Updating project <group>:<Parent Module>
25994 [INFO]         from version 8.0.1-SNAPSHOT to 8.0.1
26013 [INFO] 
26015 [INFO] Processing <group>:<Artifact 1>
26015 [INFO]     Updating parent <group>:<Parent Module>
26015 [INFO]         from version 8.0.1-SNAPSHOT to 8.0.1
26017 [INFO] 
26018 [INFO] Processing <group>:<Artifact 4>
26018 [INFO]     Updating parent <group>:<Parent Module>
26018 [INFO]         from version 8.0.1-SNAPSHOT to 8.0.1
26020 [INFO] 
26021 [INFO] Processing <group>:<Artifact 3>
26021 [INFO]     Updating parent <group>:<Parent Module>
26021 [INFO]         from version 8.0.1-SNAPSHOT to 8.0.1
26023 [INFO] 
26023 [INFO] Processing <group>:<Artifact 2>
26023 [INFO]     Updating parent <group>:<Parent Module>
26023 [INFO]         from version 8.0.1-SNAPSHOT to 8.0.1
26025 [INFO] 
26026 [INFO] ------------------------------------------------------------------------
26026 [INFO] Reactor Summary for <Project Name> 8.0.1-SNAPSHOT:
26026 [INFO] 
26026 [INFO] <Project Name> ....................................... SUCCESS [ 23.452 s]
26026 [INFO] <Module 1> ............................................. SKIPPED
26026 [INFO] <Module 2> .......................................... SKIPPED
26026 [INFO] <Module 3> .......................................... SKIPPED
26026 [INFO] <Module 4> ........................................... SKIPPED
26026 [INFO] ------------------------------------------------------------------------
26026 [INFO] BUILD SUCCESS
26026 [INFO] ------------------------------------------------------------------------
26026 [INFO] Total time:  25.372 s
26026 [INFO] Finished at: 2024-10-04T08:03:16Z
26026 [INFO] ------------------------------------------------------------------------
56759 [INFO] ------------------------------------------------------------------------
56759 [INFO] Reactor Summary for <Project Name> 8.0.1:
56759 [INFO] 
56759 [INFO] <Project Name> ....................................... FAILURE [ 43.788 s]
56759 [INFO] <Module 1> ............................................. SKIPPED
56759 [INFO] <Module 2> .......................................... SKIPPED
56759 [INFO] <Module 3> .......................................... SKIPPED
56759 [INFO] <Module 4> ........................................... SKIPPED
56759 [INFO] ------------------------------------------------------------------------
56759 [INFO] BUILD FAILURE
56759 [INFO] ------------------------------------------------------------------------
56760 [INFO] Total time:  56.060 s
56760 [INFO] Finished at: 2024-10-04T08:03:16Z
56760 [INFO] ------------------------------------------------------------------------
56760 [ERROR] Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.21.0:hotfix-finish (default-cli) on project <Parent Module>: hotfix-finish: Error re-loading project info: Some problems were encountered while processing the POMs:
56760 [ERROR] [ERROR] 'dependencies.dependency.version' for <New Dependency>:jar is missing. @ line 30, column 21
56760 [ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.amashchenko.maven.plugin:gitflow-maven-plugin:1.21.0:hotfix-finish (default-cli) on project <Parent Module>: hotfix-finish
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:347)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    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:386)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    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.reloadProjects (AbstractGitFlowMojo.java:375)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.reloadProject (AbstractGitFlowMojo.java:388)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.getCurrentProjectOutputTimestamp (AbstractGitFlowMojo.java:350)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.mvnSetVersions (AbstractGitFlowMojo.java:1190)
    at com.amashchenko.maven.plugin.gitflow.GitFlowHotfixFinishMojo.execute (GitFlowHotfixFinishMojo.java:307)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    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:
[ERROR] 'dependencies.dependency.version' for <New Dependency>:jar is missing. @ line 30, column 21
    at org.apache.maven.project.DefaultProjectBuilder.build (DefaultProjectBuilder.java:388)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.reloadProjects (AbstractGitFlowMojo.java:364)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.reloadProject (AbstractGitFlowMojo.java:388)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.getCurrentProjectOutputTimestamp (AbstractGitFlowMojo.java:350)
    at com.amashchenko.maven.plugin.gitflow.AbstractGitFlowMojo.mvnSetVersions (AbstractGitFlowMojo.java:1190)
    at com.amashchenko.maven.plugin.gitflow.GitFlowHotfixFinishMojo.execute (GitFlowHotfixFinishMojo.java:307)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:342)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:330)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:175)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:76)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:163)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:160)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:260)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:172)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:100)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:821)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:270)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    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)
56763 [ERROR] 
56763 [ERROR] Re-run Maven using the -X switch to enable full debug logging.
56763 [ERROR] 
56763 [ERROR] For more information about the errors and possible solutions, please read the following articles:
56763 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1

I hope I provided all needed information.

Kind regards,

Daniel

@jcubells
Copy link

jcubells commented Oct 8, 2024

We had the same issue, and the workaround worked so thanks a lot for that !

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