Slackbot
11/26/2023, 3:48 AMZak Taccardi
11/26/2023, 4:02 AMconfiguration
.incoming
.resolutionResult
.rootComponent
but from here, Iām not sure how to get all transitive dependenciesVampire
11/26/2023, 10:47 AMdependencies and dependencyInsight tasks. That's what those should also use.Zak Taccardi
11/27/2023, 9:46 PMprivate fun selectDependencies(rootComponent: ResolvedComponentResult): Set<DependencyResult> {
val selectedDependencies: MutableSet<DependencyResult> = LinkedHashSet()
eachDependency(
rootComponent,
selectedDependencies::add,
HashSet()
)
return selectedDependencies
}
private fun eachDependency(
node: ResolvedComponentResult,
dependencyAction: (DependencyResult) -> Unit,
visited: MutableSet<ResolvedComponentResult>
) {
if (!visited.add(node)) {
return
}
for (dependencyResult in node.dependencies) {
dependencyAction.invoke(dependencyResult)
if (dependencyResult is ResolvedDependencyResult) {
eachDependency(dependencyResult.selected, dependencyAction, visited)
}
}
}