Skip to content

Commit

Permalink
Avoid re-scanning already scanned subprojects (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
fab-10 authored Feb 4, 2022
1 parent fe6180a commit 09eea5d
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,17 @@ class LicenseResolver {
licenseSet
}

Set<ResolvedArtifact> resolveProjectDependencies(Project project) {
resolveProjectDependencies(project, new HashSet<Project>())
}

/**
* Provide full list of resolved artifacts to handle for a given project.
*
* @param project the project
* @return Set with resolved artifacts
*/
Set<ResolvedArtifact> resolveProjectDependencies(Project project) {
Set<ResolvedArtifact> resolveProjectDependencies(Project project, HashSet<Project> subprojectsAlreadyScanned) {

Set<ResolvedArtifact> dependenciesToHandle = new HashSet<ResolvedArtifact>()
def subprojects = project.rootProject.subprojects.groupBy { Project p -> "$p.group:$p.name:$p.version".toString()}
Expand All @@ -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)
}
Expand Down

0 comments on commit 09eea5d

Please sign in to comment.