From 0b3a5f2489a9b093637f85b99b74f46ebaea9f3d Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 13 Sep 2023 10:19:02 +0100 Subject: [PATCH] Ensure that check for unnecessary exclusions runs on classpath change Closes gh-37307 --- .../CheckClasspathForUnnecessaryExclusions.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java index 13b50991a5..3f39b4dacb 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/classpath/CheckClasspathForUnnecessaryExclusions.java @@ -38,6 +38,8 @@ import org.gradle.api.artifacts.ModuleDependency; import org.gradle.api.artifacts.component.ModuleComponentIdentifier; import org.gradle.api.artifacts.dsl.DependencyHandler; import org.gradle.api.artifacts.result.ResolvedArtifactResult; +import org.gradle.api.file.FileCollection; +import org.gradle.api.tasks.Classpath; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.TaskAction; @@ -61,6 +63,8 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask { private final ConfigurationContainer configurations; + private Configuration classpath; + @Inject public CheckClasspathForUnnecessaryExclusions(DependencyHandler dependencyHandler, ConfigurationContainer configurations) { @@ -72,11 +76,17 @@ public class CheckClasspathForUnnecessaryExclusions extends DefaultTask { } public void setClasspath(Configuration classpath) { + this.classpath = classpath; this.exclusionsByDependencyId.clear(); this.dependencyById.clear(); classpath.getAllDependencies().all(this::processDependency); } + @Classpath + public FileCollection getClasspath() { + return this.classpath; + } + private void processDependency(Dependency dependency) { if (dependency instanceof ModuleDependency) { processDependency((ModuleDependency) dependency);