Skip to content

Commit

Permalink
Merge pull request quarkusio#35191 from gsmet/wire-extension-updates
Browse files Browse the repository at this point in the history
Wire extension updates in quarkus update
  • Loading branch information
gsmet authored Aug 24, 2023
2 parents 5c676a5 + 53219e6 commit ba2efea
Show file tree
Hide file tree
Showing 3 changed files with 35 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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ public UpdateDependencyVersionOperation(String groupId, String artifactId, Strin
@Override
public Map<String, Object> 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(
Expand Down

0 comments on commit ba2efea

Please sign in to comment.