Skip to content

Commit

Permalink
Fixes compilation issues with gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
rpau committed May 29, 2023
1 parent 0d80fec commit 486c30e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ public TreeVisitor<?, ExecutionContext> getVisitor(Scanned acc) {
Set<String> tmpConfigurations = new HashSet<>(resolvedConfigurations);
for (String tmpConfiguration : tmpConfigurations) {
GradleDependencyConfiguration gdc = gp.getConfiguration(tmpConfiguration);
if (gdc == null || gdc.findRequestedDependency(groupId, artifactId) != null) {

if (gdc == null || gdc.getRequested().stream().filter(d -> d.getGroupId().equals(groupId)
&& d.getArtifactId().equals(artifactId)).findFirst().isPresent()) {
resolvedConfigurations.remove(tmpConfiguration);
}
}
Expand All @@ -220,7 +222,9 @@ public TreeVisitor<?, ExecutionContext> getVisitor(Scanned acc) {
GradleDependencyConfiguration gdc = gp.getConfiguration(tmpConfiguration);
for (GradleDependencyConfiguration transitive : gp.configurationsExtendingFrom(gdc, true)) {
if (resolvedConfigurations.contains(transitive.getName()) ||
(Boolean.TRUE.equals(acceptTransitive) && transitive.findResolvedDependency(groupId, artifactId) != null)) {
(Boolean.TRUE.equals(acceptTransitive) && gdc.getRequested().stream()
.filter(d -> d.getGroupId().equals(groupId)
&& d.getArtifactId().equals(artifactId)).findFirst().isPresent())) {
resolvedConfigurations.remove(transitive.getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static UncheckedConsumer<List<SourceFile>> withToolingApi(@Nullable Strin
for (int i = 0; i < sourceFiles.size(); i++) {
SourceFile sourceFile = sourceFiles.get(i);
if (sourceFile.getSourcePath().toString().endsWith(".gradle") && !sourceFile.getSourcePath().endsWith("settings.gradle")) {
OpenRewriteModel model = OpenRewriteModelBuilder.forProjectDirectory(projectDir.toFile(), tempDirectory.resolve(sourceFile.getSourcePath()).toFile());
OpenRewriteModel model = OpenRewriteModelBuilder.forProjectDirectory(projectDir.toFile());
GradleProject gradleProject = GradleProject.fromToolingModel(model.gradleProject());
sourceFiles.set(i, sourceFile.withMarkers(sourceFile.getMarkers().add(gradleProject)));
}
Expand Down

0 comments on commit 486c30e

Please sign in to comment.