Skip to content

Commit

Permalink
Wire extension updates in quarkus update
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gsmet committed Aug 24, 2023
1 parent 964ba5b commit 53219e6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,6 +52,24 @@ public static FetchResult createRecipe(MessageWriter log, Path target, MavenArti
break;
}

for (List<ExtensionUpdateInfo> 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));
}
Expand All @@ -62,19 +84,21 @@ public static class ProjectUpdateRequest {
public final String targetVersion;
public final String kotlinVersion;
public final Optional<Integer> updateJavaVersion;
public final ProjectExtensionsUpdateInfo projectExtensionsUpdateInfo;

public ProjectUpdateRequest(String currentVersion, String targetVersion, String kotlinVersion,
Optional<Integer> updateJavaVersion) {
this(BuildTool.MAVEN, currentVersion, targetVersion, kotlinVersion, updateJavaVersion);
Optional<Integer> updateJavaVersion, ProjectExtensionsUpdateInfo projectExtensionsUpdateInfo) {
this(BuildTool.MAVEN, currentVersion, targetVersion, kotlinVersion, updateJavaVersion, projectExtensionsUpdateInfo);
}

public ProjectUpdateRequest(BuildTool buildTool, String currentVersion, String targetVersion, String kotlinVersion,
Optional<Integer> updateJavaVersion) {
Optional<Integer> updateJavaVersion, ProjectExtensionsUpdateInfo projectExtensionsUpdateInfo) {
this.buildTool = buildTool;
this.currentVersion = currentVersion;
this.targetVersion = targetVersion;
this.kotlinVersion = kotlinVersion;
this.updateJavaVersion = updateJavaVersion;
this.projectExtensionsUpdateInfo = projectExtensionsUpdateInfo;
}
}
}

0 comments on commit 53219e6

Please sign in to comment.