Skip to content

Commit

Permalink
Add drop version support for update
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Sep 14, 2023
1 parent ed0e00e commit f75d108
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, Object> 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();
}
}

}

0 comments on commit f75d108

Please sign in to comment.