|
49 | 49 | import java.util.*; |
50 | 50 |
|
51 | 51 | import static java.util.Collections.*; |
| 52 | +import static java.util.Objects.requireNonNull; |
52 | 53 |
|
53 | 54 | @Value |
54 | 55 | @EqualsAndHashCode(callSuper = false) |
@@ -622,8 +623,8 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) |
622 | 623 | ((J.MethodInvocation) depArgs.get(0)).getSimpleName().equals("enforcedPlatform"))) { |
623 | 624 | m = m.withArguments(ListUtils.mapFirst(depArgs, platform -> updateDependency((J.MethodInvocation) platform, ctx))); |
624 | 625 | } |
625 | | - } else if ("ext".equals(method.getSimpleName()) && getCursor().firstEnclosingOrThrow(SourceFile.class).getSourcePath().endsWith("settings.gradle")) { |
626 | | - // rare case that gradle versions are set via settings.gradle ext block (only possible for Groovy DSL) |
| 626 | + } else if ("ext".equals(method.getSimpleName()) && isSettingsGradle()) { |
| 627 | + // rare case that gradle versions are set via settings.gradle ext block |
627 | 628 | m = (J.MethodInvocation) new JavaIsoVisitor<ExecutionContext>() { |
628 | 629 | @Override |
629 | 630 | public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext executionContext) { |
@@ -667,6 +668,11 @@ public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext ex |
667 | 668 | return m; |
668 | 669 | } |
669 | 670 |
|
| 671 | + private boolean isSettingsGradle() { |
| 672 | + String path = requireNonNull(getCursor().firstEnclosing(SourceFile.class)).getSourcePath().toString(); |
| 673 | + return path.endsWith("settings.gradle") || path.endsWith("settings.gradle.kts"); |
| 674 | + } |
| 675 | + |
670 | 676 | private J.MethodInvocation updateDependency(J.MethodInvocation method, ExecutionContext ctx) { |
671 | 677 | J.MethodInvocation m = method; |
672 | 678 | m = m.withArguments(ListUtils.map(m.getArguments(), arg -> { |
|
0 commit comments