From 09eea5de01db76f154ec806ab613e443f0f02685 Mon Sep 17 00:00:00 2001 From: fab-10 <91944855+fab-10@users.noreply.github.com> Date: Fri, 4 Feb 2022 09:05:23 +0100 Subject: [PATCH] Avoid re-scanning already scanned subprojects (#203) --- .../gradle/plugins/license/LicenseResolver.groovy | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/nl/javadude/gradle/plugins/license/LicenseResolver.groovy b/src/main/groovy/nl/javadude/gradle/plugins/license/LicenseResolver.groovy index 7c34dea..f66f3f5 100644 --- a/src/main/groovy/nl/javadude/gradle/plugins/license/LicenseResolver.groovy +++ b/src/main/groovy/nl/javadude/gradle/plugins/license/LicenseResolver.groovy @@ -132,13 +132,17 @@ class LicenseResolver { licenseSet } + Set resolveProjectDependencies(Project project) { + resolveProjectDependencies(project, new HashSet()) + } + /** * Provide full list of resolved artifacts to handle for a given project. * * @param project the project * @return Set with resolved artifacts */ - Set resolveProjectDependencies(Project project) { + Set resolveProjectDependencies(Project project, HashSet subprojectsAlreadyScanned) { Set dependenciesToHandle = new HashSet() def subprojects = project.rootProject.subprojects.groupBy { Project p -> "$p.group:$p.name:$p.version".toString()} @@ -151,11 +155,12 @@ class LicenseResolver { String dependencyDesc = "$d.moduleVersion.id.group:$d.moduleVersion.id.name:$d.moduleVersion.id.version".toString() if(isDependencyIncluded(dependencyDesc)) { Project subproject = subprojects[dependencyDesc]?.first() - if (subproject) { + if (subproject && !subprojectsAlreadyScanned.contains(subproject)) { + subprojectsAlreadyScanned.add(subproject) if(includeProjectDependencies) { dependenciesToHandle.add(d) } - dependenciesToHandle.addAll(resolveProjectDependencies(subproject)) + dependenciesToHandle.addAll(resolveProjectDependencies(subproject, subprojectsAlreadyScanned)) } else if (!subproject) { dependenciesToHandle.add(d) }