Skip to content

Commit 147550e

Browse files
authored
Parse lockfiles as plain text (#380)
1 parent 73f391d commit 147550e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

plugin/src/main/java/org/openrewrite/gradle/isolated/DefaultProjectParser.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,25 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
11201120
logger.warn("Unable to walk file tree for project {}", subproject.getPath(), e);
11211121
}
11221122

1123+
// if there is a gradle.lockfile or buildscript-gradle.lockfile parse it as plain text
1124+
// Can be renamed according to https://docs.gradle.org/current/userguide/dependency_locking.html#sec:configuring-the-per-project-lock-file-name-and-location
1125+
File lockfile = subproject.file("gradle.lockfile");
1126+
if(lockfile.exists()) {
1127+
sourceFiles = Stream.concat(sourceFiles,
1128+
PlainTextParser.builder().build()
1129+
.parse(singletonList(lockfile.toPath()), baseDir, ctx)
1130+
.map(sourceFile -> sourceFile.withMarkers(sourceFile.getMarkers().add(gradleProject)))
1131+
);
1132+
}
1133+
File buildscriptLockfile = subproject.file("buildscript-gradle.lockfile");
1134+
if(buildscriptLockfile.exists()) {
1135+
sourceFiles = Stream.concat(sourceFiles,
1136+
PlainTextParser.builder().build()
1137+
.parse(singletonList(buildscriptLockfile.toPath()), baseDir, ctx)
1138+
.map(sourceFile -> sourceFile.withMarkers(sourceFile.getMarkers().add(gradleProject)))
1139+
);
1140+
}
1141+
11231142
return SourceFileStream.build("", s -> {
11241143
}).concat(sourceFiles, gradleFileCount);
11251144
}

0 commit comments

Comments
 (0)