Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasb29 committed Nov 29, 2024
1 parent 9088903 commit 0662ad7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions plugin/src/main/java/org/openrewrite/gradle/RewritePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public void apply(Project project) {
);
});


// Because of how this Gradle has no criteria with which to select between variants of
// dependencies which expose differing capabilities. So those must be manually configured
try {
Expand All @@ -107,7 +108,7 @@ public void apply(Project project) {
} catch (final NoClassDefFoundError ex) {
// Old versions of Gradle don't have all of these attributes and that's OK
}

Provider<Set<File>> tt = project.provider(rewriteConf::resolve);
Provider<Set<File>> resolvedDependenciesProvider = project.provider(() -> getResolvedDependencies(project, extension, rewriteConf));

TaskProvider<RewriteRunTask> rewriteRun = project.getTasks().register("rewriteRun", RewriteRunTask.class, task -> {
Expand All @@ -118,7 +119,7 @@ public void apply(Project project) {

TaskProvider<RewriteDryRunTask> rewriteDryRun = project.getTasks().register("rewriteDryRun", RewriteDryRunTask.class, task -> {
task.setExtension(extension);
task.setResolvedDependencies(resolvedDependenciesProvider);
task.setResolvedDependencies(tt);
task.dependsOn(rewriteConf);
});

Expand Down Expand Up @@ -192,8 +193,14 @@ private static void configureProject(Project project, RewriteExtension extension

private Set<File> getResolvedDependencies(Project project, RewriteExtension extension, Configuration rewriteConf) {
if (resolvedDependencies == null) {
List<Dependency> knowDependencies = knownRewriteDependencies(extension, project.getDependencies());
rewriteConf.getIncoming().beforeResolve(conf -> {
rewriteConf.getDependencies().addAll(
knowDependencies
);
});
Dependency[] dependencies = Stream.concat(
knownRewriteDependencies(extension, project.getDependencies()).stream(),
knowDependencies.stream(),
rewriteConf.getDependencies().stream()
).toArray(Dependency[]::new);
// By using a detached configuration, we separate this dependency resolution from the rest of the project's
Expand All @@ -204,9 +211,7 @@ private Set<File> getResolvedDependencies(Project project, RewriteExtension exte


resolvedDependencies = detachedConf.resolve();
resolvedDependencies.stream()
.map(File::getName)
.forEach(System.out::println);

}
return resolvedDependencies;
}
Expand Down

0 comments on commit 0662ad7

Please sign in to comment.