Skip to content

Commit 012523d

Browse files
committed
Fix FindRepository matching for KTS with type information
Replace MethodMatcher-based pluginManagement/buildscript detection with simple name matching, since the synthetic class names (RewriteSettings, RewriteGradleProject) don't match the real types resolved by the K2 compiler (org.gradle.api.initialization.Settings, org.gradle.api.Project).
1 parent 8739a9e commit 012523d

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

rewrite-gradle/src/main/java/org/openrewrite/gradle/search/FindRepository.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,13 @@ public class FindRepository extends Recipe {
6161

6262
@Override
6363
public TreeVisitor<?, ExecutionContext> getVisitor() {
64-
MethodMatcher pluginManagementMatcher = new MethodMatcher("RewriteSettings pluginManagement(..)");
65-
MethodMatcher buildscriptMatcher = new MethodMatcher("RewriteGradleProject buildscript(..)");
6664
return Preconditions.check(Preconditions.or(new IsBuildGradle<>(), new IsSettingsGradle<>()), new JavaIsoVisitor<ExecutionContext>() {
6765
@Override
6866
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
6967
if (purpose == null) {
7068
return new RepositoryVisitor().visitMethodInvocation(method, ctx);
7169
} else {
72-
boolean isPluginBlock = pluginManagementMatcher.matches(method, true) || buildscriptMatcher.matches(method, true);
70+
boolean isPluginBlock = "pluginManagement".equals(method.getSimpleName()) || "buildscript".equals(method.getSimpleName());
7371
if ((purpose == Purpose.Project && !isPluginBlock) ||
7472
(purpose == Purpose.Plugin && isPluginBlock)) {
7573
return new RepositoryVisitor().visitMethodInvocation(method, ctx);

0 commit comments

Comments
 (0)