quarkusio / quarkus-updates

OpenRewrite recipes to update Quarkus projects
Apache License 2.0
10 stars 18 forks source link

quarkus update fails if the project root is not the repository/maven root #121

Closed yrodiere closed 9 months ago

yrodiere commented 10 months ago

Something wrong happens if you have a Quarkus project which lives in a subdirectory of your git repo (and, maybe, which has a parent POM in the same repo -- not sure if that's necessary).

In that case, it seems quarkus update will perform part of the update in a .mvn directory at the root of the repo, and another part in a .mvn directory in the project directory.

Real-world use case and reproducer: the hibernate-demos repo, see https://github.com/hibernate/hibernate-demos/tree/f4dd176ea3a128f5c308f4fef86b9e5cdecb1f36/hibernate-search/hsearch-feature-examples/base

Just try this from the root of your git clone:

git switch -d f4dd176ea3a128f5c308f4fef86b9e5cdecb1f36
cd hibernate-search/hsearch-feature-examples/base
quarkus update

You'll get something like this:

...
[INFO] Running recipe(s)...
[WARNING] File has been moved from hibernate-search/hsearch-feature-examples/base/.mvn/wrapper/maven-wrapper.jar to .mvn/wrapper/maven-wrapper.jar by:
[WARNING] io.quarkus.openrewrite.Quarkus
[WARNING] io.quarkus.updates.core.quarkus37.UpdateMavenWrapper
[WARNING] org.openrewrite.maven.UpdateMavenWrapper: {distributionVersion=3.9.x, addIfMissing=false}
[WARNING] Changes have been made to hibernate-search/hsearch-feature-examples/base/pom.xml by:
[WARNING] io.quarkus.openrewrite.Quarkus
[WARNING] org.openrewrite.maven.ChangePropertyValue: {key=quarkus.platform.version, newValue=3.7.1}
[WARNING] io.quarkus.updates.core.quarkus37.UpdateMavenWrapper
[WARNING] org.openrewrite.maven.UpdateMavenWrapper: {distributionVersion=3.9.x, addIfMissing=false}
[WARNING] io.quarkus.updates.core.quarkus37.MavenPlugins
[WARNING] org.openrewrite.maven.UpgradePluginVersion: {groupId=org.apache.maven.plugins, artifactId=maven-compiler-plugin, newVersion=3.12.1}
[WARNING] org.openrewrite.maven.UpgradePluginVersion: {groupId=org.apache.maven.plugins, artifactId=maven-surefire-plugin, newVersion=3.2.3}
[WARNING] Changes have been made to hibernate-search/hsearch-feature-examples/base/.mvn/wrapper/maven-wrapper.properties by:
[WARNING] io.quarkus.openrewrite.Quarkus
[WARNING] io.quarkus.updates.core.quarkus37.UpdateMavenWrapper
[WARNING] org.openrewrite.maven.UpdateMavenWrapper: {distributionVersion=3.9.x, addIfMissing=false}
[WARNING] Please review and commit the results.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  19.993 s
[INFO] Finished at: 2024-02-06T09:25:59+01:00
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] 
[INFO] 
[INFO] 
[INFO] 
[INFO] 
[INFO]  ------------------------------------------------------------------------
[INFO] Executing:
/home/yrodiere/workspaces/community/hibernate-demos/hibernate-search/hsearch-feature-examples/base/mvnw process-sources
[INFO] 
[ERROR] Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.
[ERROR] Investigate or delete /home/yrodiere/workspaces/community/hibernate-demos/hibernate-search/hsearch-feature-examples/base/.mvn/wrapper/maven-wrapper.jar to attempt a clean download.
[ERROR] If you updated your Maven version, you need to update the specified wrapperSha256Sum property.
[INFO] 
[INFO] 
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  26.852 s
[INFO] Finished at: 2024-02-06T09:26:00+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:3.6.0:update (default-cli) on project hsearch-feature-examples-base: The command to update the project exited with an error, see the execution logs above for more details -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal io.quarkus:quarkus-maven-plugin:3.6.0:update (default-cli) on project hsearch-feature-examples-base: The command to update the project exited with an error, see the execution logs above for more details
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    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:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    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:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    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.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)
Caused by: org.apache.maven.plugin.MojoExecutionException: The command to update the project exited with an error, see the execution logs above for more details
    at io.quarkus.maven.UpdateMojo.processProjectState (UpdateMojo.java:136)
    at io.quarkus.maven.QuarkusProjectStateMojoBase.doExecute (QuarkusProjectStateMojoBase.java:59)
    at io.quarkus.maven.QuarkusProjectMojoBase.execute (QuarkusProjectMojoBase.java:117)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
    at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
    at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
    at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
    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:261)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
    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:283)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:226)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:407)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:348)
    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.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:52)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:161)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:73)
[ERROR] 
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[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/MojoExecutionException

And git status will output this:

$ git status
HEAD detached at f4dd176
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    .mvn/wrapper/maven-wrapper.jar
        modified:   .mvn/wrapper/maven-wrapper.properties
        modified:   pom.xml

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ../../../.mvn/

no changes added to commit (use "git add" and/or "git commit -a")
gsmet commented 9 months ago

This will be fixed by https://github.com/openrewrite/rewrite/pull/3989 so I'll try to reintroduce the recipe once it's in an OpenRewrite release.