Skip to content

Commit

Permalink
Separate
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasb29 committed Nov 29, 2024
1 parent 0662ad7 commit 3cb8a98
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions plugin/src/main/java/org/openrewrite/gradle/RewritePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,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 @@ -119,7 +119,7 @@ public void apply(Project project) {

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

Expand Down Expand Up @@ -193,14 +193,8 @@ 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(
knowDependencies.stream(),
knownRewriteDependencies(extension, project.getDependencies()).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 Down

0 comments on commit 3cb8a98

Please sign in to comment.