diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/UpdateProjectCommandHandler.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/UpdateProjectCommandHandler.java index 8620be2106740..beda98f33c169 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/UpdateProjectCommandHandler.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/commands/handlers/UpdateProjectCommandHandler.java @@ -109,8 +109,6 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws String rewritePluginVersion = invocation.getValue(UpdateProject.REWRITE_PLUGIN_VERSION, fetchResult.getRewritePluginVersion()); boolean rewriteDryRun = invocation.getValue(UpdateProject.REWRITE_DRY_RUN, false); - invocation.log().warn( - "The update feature does not yet handle updates of the extension versions. If needed, update your extensions manually."); QuarkusUpdateCommand.handle( invocation.log(), buildTool, diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdates.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdates.java index cedfb6d0fb0d5..efda3dc62d0b0 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdates.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/QuarkusUpdates.java @@ -10,6 +10,7 @@ import io.quarkus.devtools.project.update.ExtensionUpdateInfo; import io.quarkus.devtools.project.update.ProjectExtensionsUpdateInfo; import io.quarkus.devtools.project.update.rewrite.QuarkusUpdatesRepository.FetchResult; +import io.quarkus.devtools.project.update.rewrite.operations.DropDependencyVersionOperation; import io.quarkus.devtools.project.update.rewrite.operations.UpdateDependencyVersionOperation; import io.quarkus.devtools.project.update.rewrite.operations.UpdateJavaVersionOperation; import io.quarkus.devtools.project.update.rewrite.operations.UpdatePropertyOperation; @@ -60,7 +61,9 @@ public static FetchResult createRecipe(MessageWriter log, Path target, MavenArti .getSimpleVersionUpdates()) { if (versionUpdates.getVersionUpdateType() .equals(ExtensionUpdateInfo.VersionUpdateType.RECOMMEND_PLATFORM_MANAGED)) { - // Dropping the version is not supported yet by open-rewrite: https://github.com/openrewrite/rewrite/issues/3546 + recipe.addOperation(new DropDependencyVersionOperation( + versionUpdates.getCurrentDep().getArtifact().getGroupId(), + versionUpdates.getCurrentDep().getArtifact().getArtifactId())); } else { recipe.addOperation(new UpdateDependencyVersionOperation( versionUpdates.getCurrentDep().getArtifact().getGroupId(), diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/DropDependencyVersionOperation.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/DropDependencyVersionOperation.java new file mode 100644 index 0000000000000..60eecb6c787d8 --- /dev/null +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/DropDependencyVersionOperation.java @@ -0,0 +1,32 @@ +package io.quarkus.devtools.project.update.rewrite.operations; + +import java.util.Map; + +import io.quarkus.devtools.project.BuildTool; +import io.quarkus.devtools.project.update.rewrite.RewriteOperation; + +public class DropDependencyVersionOperation implements RewriteOperation { + + private final String groupId; + private final String artifactId; + + public DropDependencyVersionOperation(String groupId, String artifactId) { + this.groupId = groupId; + this.artifactId = artifactId; + } + + @Override + public Map single(BuildTool buildTool) { + switch (buildTool) { + // Gradle is not yet implemented: https://github.com/openrewrite/rewrite/issues/3546 + case MAVEN: + return Map.of("org.openrewrite.maven.RemoveRedundantDependencyVersions", + Map.of( + "groupId", groupId, + "artifactId", artifactId)); + default: + return Map.of(); + } + } + +}