From 0662ad7283e65203d100b657ce56221804577a95 Mon Sep 17 00:00:00 2001 From: nicolasb29 Date: Fri, 29 Nov 2024 21:31:27 +0100 Subject: [PATCH] test --- .../org/openrewrite/gradle/RewritePlugin.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugin/src/main/java/org/openrewrite/gradle/RewritePlugin.java b/plugin/src/main/java/org/openrewrite/gradle/RewritePlugin.java index 174bbf9b8..86c28cd86 100644 --- a/plugin/src/main/java/org/openrewrite/gradle/RewritePlugin.java +++ b/plugin/src/main/java/org/openrewrite/gradle/RewritePlugin.java @@ -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 { @@ -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> tt = project.provider(rewriteConf::resolve); Provider> resolvedDependenciesProvider = project.provider(() -> getResolvedDependencies(project, extension, rewriteConf)); TaskProvider rewriteRun = project.getTasks().register("rewriteRun", RewriteRunTask.class, task -> { @@ -118,7 +119,7 @@ public void apply(Project project) { TaskProvider rewriteDryRun = project.getTasks().register("rewriteDryRun", RewriteDryRunTask.class, task -> { task.setExtension(extension); - task.setResolvedDependencies(resolvedDependenciesProvider); + task.setResolvedDependencies(tt); task.dependsOn(rewriteConf); }); @@ -192,8 +193,14 @@ private static void configureProject(Project project, RewriteExtension extension private Set getResolvedDependencies(Project project, RewriteExtension extension, Configuration rewriteConf) { if (resolvedDependencies == null) { + List 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 @@ -204,9 +211,7 @@ private Set getResolvedDependencies(Project project, RewriteExtension exte resolvedDependencies = detachedConf.resolve(); - resolvedDependencies.stream() - .map(File::getName) - .forEach(System.out::println); + } return resolvedDependencies; }