Skip to content

Commit 3d97a63

Browse files
committed
Ensure RemoveDependency will work correctly when constructed reflectively
1 parent 20846d2 commit 3d97a63

1 file changed

Lines changed: 2 additions & 20 deletions

File tree

src/main/java/org/openrewrite/java/dependencies/RemoveDependency.java

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,24 +79,6 @@ public Map<JavaProject, Boolean> getInitialValue(ExecutionContext ctx) {
7979
return new HashMap<>();
8080
}
8181

82-
org.openrewrite.gradle.RemoveDependency removeGradleDependency;
83-
org.openrewrite.maven.RemoveDependency removeMavenDependency;
84-
85-
public RemoveDependency(
86-
String groupId,
87-
String artifactId,
88-
@Nullable String unlessUsing,
89-
@Nullable String configuration,
90-
@Nullable String scope) {
91-
this.groupId = groupId;
92-
this.artifactId = artifactId;
93-
this.unlessUsing = unlessUsing;
94-
this.configuration = configuration;
95-
this.scope = scope;
96-
removeGradleDependency = new org.openrewrite.gradle.RemoveDependency(groupId, artifactId, configuration);
97-
removeMavenDependency = new org.openrewrite.maven.RemoveDependency(groupId, artifactId, scope);
98-
}
99-
10082
@Override
10183
public TreeVisitor<?, ExecutionContext> getScanner(Map<JavaProject, Boolean> projectToInUse) {
10284
if (unlessUsing == null) {
@@ -117,8 +99,8 @@ public Tree preVisit(Tree tree, ExecutionContext ctx) {
11799
@Override
118100
public TreeVisitor<?, ExecutionContext> getVisitor(Map<JavaProject, Boolean> projectToInUse) {
119101
return new TreeVisitor<Tree, ExecutionContext>() {
120-
final TreeVisitor<?, ExecutionContext> gradleRemoveDep = removeGradleDependency.getVisitor();
121-
final TreeVisitor<?, ExecutionContext> mavenRemoveDep = removeMavenDependency.getVisitor();
102+
final TreeVisitor<?, ExecutionContext> gradleRemoveDep = new org.openrewrite.gradle.RemoveDependency(groupId, artifactId, configuration).getVisitor();
103+
final TreeVisitor<?, ExecutionContext> mavenRemoveDep = new org.openrewrite.maven.RemoveDependency(groupId, artifactId, scope).getVisitor();
122104

123105
@Override
124106
public @Nullable Tree visit(@Nullable Tree tree, ExecutionContext ctx) {

0 commit comments

Comments
 (0)