diff --git a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyClassifier.java b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyClassifier.java index 4ff6a8d96ab..7155dbcc702 100644 --- a/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyClassifier.java +++ b/rewrite-maven/src/main/java/org/openrewrite/maven/ChangeDependencyClassifier.java @@ -54,12 +54,12 @@ public class ChangeDependencyClassifier extends Recipe { @Nullable String newClassifier; - @Option(displayName = "Include managed dependencies", - description = "Whether to include managed dependencies in the search. Defaults to false.", + @Option(displayName = "Only on managed dependencies", + description = "Whether to only consider managed dependencies in the search. Defaults to false.", example = "true", required = false) @Nullable - Boolean includeManaged; + Boolean onlyManaged; @Override public String getDisplayName() { @@ -76,7 +76,9 @@ public TreeVisitor getVisitor() { return new MavenVisitor() { @Override public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) { - if (isDependencyTag(groupId, artifactId) || (includeManaged != null && includeManaged && isManagedDependencyTag(groupId, artifactId))) { + boolean managedOnly = onlyManaged != null && onlyManaged; + if ((!managedOnly && isDependencyTag(groupId, artifactId)) || + (managedOnly && isManagedDependencyTag(groupId, artifactId))) { Optional scope = tag.getChild("classifier"); if (scope.isPresent()) { if (newClassifier == null) { diff --git a/rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyClassifierTest.java b/rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyClassifierTest.java index a16b114b571..444564678a1 100644 --- a/rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyClassifierTest.java +++ b/rewrite-maven/src/test/java/org/openrewrite/maven/ChangeDependencyClassifierTest.java @@ -128,7 +128,6 @@ void noManagedClassifierToClassifier() { org.ehcache ehcache - jakarta