Skip to content

Commit ec64ae3

Browse files
committed
Remove redundant isPrimaryBuildFile check from UpgradeTransitiveDependencyVersion
Applied scripts like dependencies.gradle already don't get constraints added due to the DEPENDENCIES_DSL_MATCHER not matching non-type-attributed method invocations in applied scripts. The isPrimaryBuildFile guard was redundant. The actual fix is the DependencyConstraintToRule isEmptyDependenciesBlock change (from the previous commit) which properly cleans up empty dependencies {} blocks after constraints are converted to resolutionStrategy.
1 parent df1cad8 commit ec64ae3

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -520,10 +520,7 @@ private class UpdateGradle extends JavaVisitor<ExecutionContext> {
520520
if (tree instanceof JavaSourceFile) {
521521
JavaSourceFile cu = (JavaSourceFile) tree;
522522
GradleProject gradleProject = cu.getMarkers().findFirst(GradleProject.class).orElse(null);
523-
// Only add constraints to primary build files, not to applied scripts like dependencies.gradle
524-
String fileName = cu.getSourcePath().getFileName().toString();
525-
boolean isPrimaryBuildFile = "build.gradle".equals(fileName) || "build.gradle.kts".equals(fileName);
526-
Map<GroupArtifact, Map<GradleDependencyConfiguration, String>> projectRequiredUpdates = gradleProject != null && isPrimaryBuildFile ? acc.updatesPerProject.getOrDefault(getGradleProjectKey(gradleProject), emptyMap()) : emptyMap();
523+
Map<GroupArtifact, Map<GradleDependencyConfiguration, String>> projectRequiredUpdates = gradleProject != null ? acc.updatesPerProject.getOrDefault(getGradleProjectKey(gradleProject), emptyMap()) : emptyMap();
527524
if (projectRequiredUpdates.keySet().stream().anyMatch(ga -> dependencyMatcher.matches(ga.getGroupId(), ga.getArtifactId()))) {
528525
cu = (JavaSourceFile) Preconditions.check(
529526
not(new JavaIsoVisitor<ExecutionContext>() {

0 commit comments

Comments
 (0)