Skip to content

Commit

Permalink
refactor(Conan): Utilize buildSet() in parseDependencyTree()
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed May 17, 2023
1 parent 7872608 commit 1a8f2d0
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions plugins/package-managers/conan/src/main/kotlin/Conan.kt
Original file line number Diff line number Diff line change
Expand Up @@ -267,25 +267,22 @@ class Conan(
pkg: JsonNode,
scopeName: String,
workingDir: File
): Set<PackageReference> {
val result = mutableSetOf<PackageReference>()

pkg[scopeName]?.forEach { childNode ->
val childRef = childNode.textValueOrEmpty()
pkgInfos.find { it["reference"].textValueOrEmpty() == childRef }?.let { pkgInfo ->
logger.debug { "Found child '$childRef'." }
): Set<PackageReference> =
buildSet {
pkg[scopeName]?.forEach { childNode ->
val childRef = childNode.textValueOrEmpty()
pkgInfos.find { it["reference"].textValueOrEmpty() == childRef }?.let { pkgInfo ->
logger.debug { "Found child '$childRef'." }

val id = parsePackageId(pkgInfo, workingDir)
val dependencies = parseDependencyTree(pkgInfos, pkgInfo, SCOPE_NAME_DEPENDENCIES, workingDir) +
parseDependencyTree(pkgInfos, pkgInfo, SCOPE_NAME_DEV_DEPENDENCIES, workingDir)
val id = parsePackageId(pkgInfo, workingDir)
val dependencies = parseDependencyTree(pkgInfos, pkgInfo, SCOPE_NAME_DEPENDENCIES, workingDir) +
parseDependencyTree(pkgInfos, pkgInfo, SCOPE_NAME_DEV_DEPENDENCIES, workingDir)

result += PackageReference(id, dependencies = dependencies)
this += PackageReference(id, dependencies = dependencies)
}
}
}

return result
}

/**
* Run through each package and parse the list of its dependencies (also transitive ones).
*/
Expand Down

0 comments on commit 1a8f2d0

Please sign in to comment.