Skip to content

Commit e96301c

Browse files
authored
Revert "Support for external properties for UpgradeTransitiveDependencyVersion recipe (#5756)" (#5791)
* Revert "Support for external properties for UpgradeTransitiveDependencyVersion recipe (#5756)" This reverts commit f015848. * Polish
1 parent 4483f65 commit e96301c

3 files changed

Lines changed: 94 additions & 500 deletions

File tree

rewrite-gradle/src/main/java/org/openrewrite/gradle/UpgradeDependencyVersion.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.util.*;
5050

5151
import static java.util.Collections.*;
52+
import static java.util.Objects.requireNonNull;
5253

5354
@Value
5455
@EqualsAndHashCode(callSuper = false)
@@ -622,8 +623,8 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
622623
((J.MethodInvocation) depArgs.get(0)).getSimpleName().equals("enforcedPlatform"))) {
623624
m = m.withArguments(ListUtils.mapFirst(depArgs, platform -> updateDependency((J.MethodInvocation) platform, ctx)));
624625
}
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
627628
m = (J.MethodInvocation) new JavaIsoVisitor<ExecutionContext>() {
628629
@Override
629630
public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext executionContext) {
@@ -667,6 +668,11 @@ public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext ex
667668
return m;
668669
}
669670

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+
670676
private J.MethodInvocation updateDependency(J.MethodInvocation method, ExecutionContext ctx) {
671677
J.MethodInvocation m = method;
672678
m = m.withArguments(ListUtils.map(m.getArguments(), arg -> {

0 commit comments

Comments
 (0)