diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java index fe6d16c3df..f278410a57 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java @@ -30,6 +30,7 @@ import org.gradle.api.GradleException; import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.ResolvableDependencies; import org.gradle.util.GradleVersion; import org.springframework.boot.gradle.dsl.SpringBootExtension; @@ -42,6 +43,7 @@ import org.springframework.boot.gradle.tasks.bundling.BootWar; * @author Phillip Webb * @author Dave Syer * @author Andy Wilkinson + * @author Danny Hyun */ public class SpringBootPlugin implements Plugin { @@ -120,11 +122,16 @@ public class SpringBootPlugin implements Plugin { private void unregisterUnresolvedDependenciesAnalyzer(Project project) { UnresolvedDependenciesAnalyzer unresolvedDependenciesAnalyzer = new UnresolvedDependenciesAnalyzer(); - project.getConfigurations().all((configuration) -> configuration.getIncoming() - .afterResolve((resolvableDependencies) -> unresolvedDependenciesAnalyzer - .analyze(configuration.getResolvedConfiguration() - .getLenientConfiguration() - .getUnresolvedModuleDependencies()))); + project.getConfigurations().all((configuration) -> { + ResolvableDependencies incoming = configuration.getIncoming(); + incoming.afterResolve((resolvableDependencies) -> { + if (incoming.equals(resolvableDependencies)) { + unresolvedDependenciesAnalyzer.analyze(configuration + .getResolvedConfiguration().getLenientConfiguration() + .getUnresolvedModuleDependencies()); + } + }); + }); project.getGradle().buildFinished( (buildResult) -> unresolvedDependenciesAnalyzer.buildFinished(project)); }