From 964ba5b8b26b13f7eb207d101b56734640d9ec89 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 3 Aug 2023 16:59:30 +0200 Subject: [PATCH 1/2] Handle update dependency version operation for Gradle --- .../operations/UpdateDependencyVersionOperation.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/UpdateDependencyVersionOperation.java b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/UpdateDependencyVersionOperation.java index 18c6f1c58741b..3a8fabb65fd20 100644 --- a/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/UpdateDependencyVersionOperation.java +++ b/independent-projects/tools/devtools-common/src/main/java/io/quarkus/devtools/project/update/rewrite/operations/UpdateDependencyVersionOperation.java @@ -20,6 +20,12 @@ public UpdateDependencyVersionOperation(String groupId, String artifactId, Strin @Override public Map single(BuildTool buildTool) { switch (buildTool) { + case GRADLE: + return Map.of("org.openrewrite.gradle.UpgradeDependencyVersion", + Map.of( + "groupId", groupId, + "artifactId", artifactId, + "newVersion", newVersion)); case MAVEN: return Map.of("org.openrewrite.maven.UpgradeDependencyVersion", Map.of( From 53219e6ecdb1454f6e5cab246be8138c07506d90 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 3 Aug 2023 16:59:46 +0200 Subject: [PATCH 2/2] Wire extension updates in quarkus update Note that this is a preliminar effort and it is not handling all the possibilities. Handling the other possibilities might be problematic given how we apply the recipes to a root module of a multi-module project. --- .../handlers/UpdateProjectCommandHandler.java | 3 +- .../update/rewrite/QuarkusUpdates.java | 30 +++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) 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 c57d632913688..3b1b268de1d07 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 @@ -91,7 +91,8 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws projectQuarkusPlatformBom.getVersion(), targetPlatformVersion, kotlinVersion, - updateJavaVersion); + updateJavaVersion, + extensionsUpdateInfo); Path recipe = null; try { recipe = Files.createTempFile("quarkus-project-recipe-", ".yaml"); 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 b5c45ab54e708..93da116b84068 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 @@ -2,12 +2,16 @@ import java.io.IOException; import java.nio.file.Path; +import java.util.List; import java.util.Optional; import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver; import io.quarkus.devtools.messagewriter.MessageWriter; import io.quarkus.devtools.project.BuildTool; +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.UpdateDependencyVersionOperation; import io.quarkus.devtools.project.update.rewrite.operations.UpdateJavaVersionOperation; import io.quarkus.devtools.project.update.rewrite.operations.UpdatePropertyOperation; import io.quarkus.devtools.project.update.rewrite.operations.UpgradeGradlePluginOperation; @@ -48,6 +52,24 @@ public static FetchResult createRecipe(MessageWriter log, Path target, MavenArti break; } + for (List nonPlatformExtensionsUpdates : request.projectExtensionsUpdateInfo + .getNonPlatformExtensions().values()) { + for (ExtensionUpdateInfo nonPlatformExtensionsUpdate : nonPlatformExtensionsUpdates) { + if (nonPlatformExtensionsUpdate.getCurrentDep().isPlatformExtension()) { + // add, my understanding is that we should define the version? As a dependency, as a managed one? + // not completely sure how to make it work for a multi-module project? + } else if (nonPlatformExtensionsUpdate.getRecommendedDependency().isPlatformExtension()) { + // remove, decide what to do here, should we remove the version given it is now managed? Will OpenRewrite support that? + // not completely sure how to make it work for a multi-module project? + } else { + recipe.addOperation(new UpdateDependencyVersionOperation( + nonPlatformExtensionsUpdate.getCurrentDep().getArtifact().getGroupId(), + nonPlatformExtensionsUpdate.getCurrentDep().getArtifact().getArtifactId(), + nonPlatformExtensionsUpdate.getRecommendedDependency().getVersion())); + } + } + } + for (String s : result.getRecipes()) { recipe.addRecipes(QuarkusUpdateRecipeIO.readRecipesYaml(s)); } @@ -62,19 +84,21 @@ public static class ProjectUpdateRequest { public final String targetVersion; public final String kotlinVersion; public final Optional updateJavaVersion; + public final ProjectExtensionsUpdateInfo projectExtensionsUpdateInfo; public ProjectUpdateRequest(String currentVersion, String targetVersion, String kotlinVersion, - Optional updateJavaVersion) { - this(BuildTool.MAVEN, currentVersion, targetVersion, kotlinVersion, updateJavaVersion); + Optional updateJavaVersion, ProjectExtensionsUpdateInfo projectExtensionsUpdateInfo) { + this(BuildTool.MAVEN, currentVersion, targetVersion, kotlinVersion, updateJavaVersion, projectExtensionsUpdateInfo); } public ProjectUpdateRequest(BuildTool buildTool, String currentVersion, String targetVersion, String kotlinVersion, - Optional updateJavaVersion) { + Optional updateJavaVersion, ProjectExtensionsUpdateInfo projectExtensionsUpdateInfo) { this.buildTool = buildTool; this.currentVersion = currentVersion; this.targetVersion = targetVersion; this.kotlinVersion = kotlinVersion; this.updateJavaVersion = updateJavaVersion; + this.projectExtensionsUpdateInfo = projectExtensionsUpdateInfo; } } }