alx3apps / jgit-buildnumber

Git buildnumber for Maven and Ant without Git CLI
51 stars 23 forks source link

Plugin fails when used with the Maven release plugin #31

Closed robertpatrick closed 2 years ago

robertpatrick commented 2 years ago

We use the Maven release plugin to cut releases of our software (i.e., mvn -B release:prepare release:perform). With the 3.0.0-M4 version of the Maven release plugin, we see a stack trace that indicates a commit was missing while it is building the official release version.

INFO] [INFO] Building weblogic-deploy-installer 2.0.0                           [3/5]
[INFO] [INFO] --------------------------------[ pom ]---------------------------------
[INFO] [INFO] 
[INFO] [INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-build-environment) @ weblogic-deploy-installer ---
[INFO] [INFO] 
[INFO] [INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-wlst) @ weblogic-deploy-installer ---
[INFO] [INFO] 
[INFO] [INFO] --- maven-jgit-buildnumber-plugin:1.2.10:extract-buildnumber (git-buildnumber) @ weblogic-deploy-installer ---
[INFO] [ERROR] 
[INFO] org.eclipse.jgit.errors.RevWalkException: Walk failure.
[INFO]     at org.eclipse.jgit.revwalk.RevWalk.iterator (RevWalk.java:1231)
[INFO]     at ru.concerteza.util.buildnumber.BuildNumberExtractor.countCommits (BuildNumberExtractor.java:142)
[INFO]     at ru.concerteza.util.buildnumber.BuildNumberExtractor.extract (BuildNumberExtractor.java:55)
[INFO]     at ru.concerteza.util.buildnumber.JGitBuildNumberMojo.execute (JGitBuildNumberMojo.java:137)
[INFO]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
[INFO]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
[INFO]     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
[INFO]     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
[INFO]     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
[INFO]     at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
[INFO]     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
[INFO]     at java.lang.reflect.Method.invoke (Method.java:498)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] Caused by: org.eclipse.jgit.errors.MissingObjectException: Missing commit 4aa915de8f2dc2232c0337916f7fc2d3b41d8d7c
[INFO]     at org.eclipse.jgit.storage.file.WindowCursor.open (WindowCursor.java:126)
[INFO]     at org.eclipse.jgit.revwalk.RevWalk.getCachedBytes (RevWalk.java:856)
[INFO]     at org.eclipse.jgit.revwalk.RevCommit.parseHeaders (RevCommit.java:136)
[INFO]     at org.eclipse.jgit.revwalk.PendingGenerator.next (PendingGenerator.java:148)
[INFO]     at org.eclipse.jgit.revwalk.StartGenerator.next (StartGenerator.java:181)
[INFO]     at org.eclipse.jgit.revwalk.RevWalk.next (RevWalk.java:420)
[INFO]     at org.eclipse.jgit.revwalk.RevWalk.iterator (RevWalk.java:1229)
[INFO]     at ru.concerteza.util.buildnumber.BuildNumberExtractor.countCommits (BuildNumberExtractor.java:142)
[INFO]     at ru.concerteza.util.buildnumber.BuildNumberExtractor.extract (BuildNumberExtractor.java:55)
[INFO]     at ru.concerteza.util.buildnumber.JGitBuildNumberMojo.execute (JGitBuildNumberMojo.java:137)
[INFO]     at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
[INFO]     at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
[INFO]     at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
[INFO]     at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
[INFO]     at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
[INFO]     at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
[INFO]     at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
[INFO]     at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
[INFO]     at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
[INFO]     at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
[INFO]     at java.lang.reflect.Method.invoke (Method.java:498)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
[INFO]     at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] [INFO] 

However, if I do git checkout <release tag>, then run git log, the commit in question (second one in the list) is shown.

rpatrick@rpatrick-mac weblogic-deploy-tooling % git log
commit 2d965e1f356ebc6132faf7ae5392312d1571f459 (HEAD, tag: release-2.0.0)
Author: Robert Patrick <redacted@oracle.com>
Date:   Thu Jan 27 09:06:26 2022 -0600

    [maven-release-plugin] prepare release release-2.0.0

commit 4aa915de8f2dc2232c0337916f7fc2d3b41d8d7c (origin/main, origin/HEAD)
Author: Rosemary Marano <redacted@oracle.com>
Date:   Thu Jan 27 09:42:03 2022 -0500

    update-repo-doc-links (#1060)

    * update-repo-doc-links

    * re-fix project repo links

commit 165f8290d0f84ae02ab2ef2495ff2a0ca77c6273
Merge: 535f7d59 3916708c
Author: Robert Patrick <31662131+robertpatrick@users.noreply.github.com>
Date:   Wed Jan 26 14:25:01 2022 -0600

    Merge pull request #1061 from oracle/empty-yaml-file

:

Furthermore, if I run the Maven build from the release tag, it works properly:

rpatrick@rpatrick-mac weblogic-deploy-tooling % mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] Oracle WebLogic Server Deploy Tooling                              [pom]
[INFO] weblogic-deploy-core                                               [jar]
[INFO] weblogic-deploy-installer                                          [pom]
[INFO] weblogic-deploy-system-test                                        [pom]
[INFO] weblogic-deploy-alias-test                                         [pom]
[INFO] 
[INFO] -----------< com.oracle.weblogic.lifecycle:weblogic-deploy >------------
[INFO] Building Oracle WebLogic Server Deploy Tooling 2.0.0               [1/5]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ weblogic-deploy ---
[INFO] Deleting /Users/rpatrick/Projects/weblogic-deploy-tooling/target
[INFO] 
[INFO] --- flatten-maven-plugin:1.2.7:clean (flatten.clean) @ weblogic-deploy ---
[INFO] Deleting /Users/rpatrick/Projects/weblogic-deploy-tooling/.flattened-pom.xml
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-build-environment) @ weblogic-deploy ---
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-wlst) @ weblogic-deploy ---
[INFO] 
[INFO] --- flatten-maven-plugin:1.2.7:flatten (flatten) @ weblogic-deploy ---
[INFO] Generating flattened POM of project com.oracle.weblogic.lifecycle:weblogic-deploy:pom:2.0.0...
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ weblogic-deploy ---
[INFO] Installing /Users/rpatrick/Projects/weblogic-deploy-tooling/pom.xml to /Users/rpatrick/.m2/repository/com/oracle/weblogic/lifecycle/weblogic-deploy/2.0.0/weblogic-deploy-2.0.0.pom
[INFO] 
[INFO] ---------< com.oracle.weblogic.lifecycle:weblogic-deploy-core >---------
[INFO] Building weblogic-deploy-core 2.0.0                                [2/5]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ weblogic-deploy-core ---
[INFO] Deleting /Users/rpatrick/Projects/weblogic-deploy-tooling/core/target
[INFO] 
[INFO] --- flatten-maven-plugin:1.2.7:clean (flatten.clean) @ weblogic-deploy-core ---
[INFO] Deleting /Users/rpatrick/Projects/weblogic-deploy-tooling/core/.flattened-pom.xml
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-build-environment) @ weblogic-deploy-core ---
[INFO] 
[INFO] --- maven-enforcer-plugin:3.0.0:enforce (enforce-wlst) @ weblogic-deploy-core ---
[INFO] 
[INFO] --- maven-jgit-buildnumber-plugin:1.2.10:extract-buildnumber (git-buildnumber) @ weblogic-deploy-core ---
[INFO] Git info extracted, revision: '2d965e1', branch: '', tag: 'release-2.0.0', commitsCount: '1570', commitDate: '2022-01-27', buildnumber: 'release-2.0.0.1570.2d965e1'
[INFO] 
...
robertpatrick commented 2 years ago

@elab, does this help?

rpatrick@rpatrick-mac weblogic-deploy-tooling % git show release-2.0.0
tag release-2.0.0
Tagger: Robert Patrick <redacted@oracle.com>
Date:   Thu Jan 27 09:06:29 2022 -0600

[maven-release-plugin] copy for tag release-2.0.0

commit 2d965e1f356ebc6132faf7ae5392312d1571f459 (tag: release-2.0.0)
Author: Robert Patrick <redacted@oracle.com>
Date:   Thu Jan 27 09:06:26 2022 -0600

    [maven-release-plugin] prepare release release-2.0.0
...
elab commented 2 years ago

Hi Robert, sorry, I deleted my comment, since after the second thought it seemed not related (fwiw, the plugin v3 still creates annotated tags like v2).

I think, in your case the Git database could rather be damaged (-> git fsck), but this seems strange, too. Perhaps something went wrong due to beta state of the maven-release-plugin? With 2.5.3 everything ok?

If still not and the Git repo is in good order, then the version of JGit (org.eclipse.jgit) used in the jgit-buildnumber is probably outdated. In this case you could also try my fork of jgit-buildnumber, which uses a much newer JGit version and has a lot of other improvements, by the way (including recognition of lightweight tags, which was my first thought your case could be related to).

robertpatrick commented 2 years ago

@elab I am 100% sure this is not related to a "damaged Git database" as this is happening on multiple machines for multiple users.

I can try the forked repo the next time we are preparing to release.

robertpatrick commented 2 years ago

@elab I verified that using your plug-in resolves my issue. It seems that this repo/plug-in has been abandoned so we will switch permanently to your plug-in.

elab commented 2 years ago

Thank you for the feedback. Glad I could help.