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; } } } 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(