Skip to content

Commit

Permalink
Change from includeManaged to onlyManaged to not apply twice
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Dec 16, 2023
1 parent 8ba4024 commit b7d777d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -76,7 +76,9 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
return new MavenVisitor<ExecutionContext>() {
@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<Xml.Tag> scope = tag.getChild("classifier");
if (scope.isPresent()) {
if (newClassifier == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ void noManagedClassifierToClassifier() {
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<classifier>jakarta</classifier>
</dependency>
</dependencies>
</project>
Expand Down

0 comments on commit b7d777d

Please sign in to comment.