mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Add optional filter for transitive closure.
This commit is contained in:
parent
11980ca940
commit
47f7072d9c
2 changed files with 17 additions and 13 deletions
|
@ -65,15 +65,18 @@ class DynamicGraph<T> {
|
|||
}
|
||||
}
|
||||
|
||||
fun <T> transitiveClosureGraph(roots: List<T>, childrenFor: (T) -> List<T>) : List<Node<T>>
|
||||
= roots.map { transitiveClosureGraph(it, childrenFor) }
|
||||
fun <T> transitiveClosureGraph(roots: List<T>, childrenFor: (T) -> List<T>,
|
||||
filter: (T) -> Boolean): List<Node<T>>
|
||||
= roots.map { transitiveClosureGraph(it, childrenFor, filter) }
|
||||
|
||||
fun <T> transitiveClosureGraph(root: T, childrenFor: (T) -> List<T>, seen: HashSet<T> = hashSetOf()) : Node<T> {
|
||||
fun <T> transitiveClosureGraph(root: T, childrenFor: (T) -> List<T>,
|
||||
filter: (T) -> Boolean = { t: T -> true },
|
||||
seen: HashSet<T> = hashSetOf()) : Node<T> {
|
||||
val children = arrayListOf<Node<T>>()
|
||||
childrenFor(root).forEach { child ->
|
||||
childrenFor(root).filter(filter).forEach { child ->
|
||||
if (! seen.contains(child)) {
|
||||
seen.add(child)
|
||||
val c = transitiveClosureGraph(child, childrenFor, seen)
|
||||
val c = transitiveClosureGraph(child, childrenFor, filter, seen)
|
||||
children.add(c)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,20 +67,21 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v
|
|||
children = node.children.map { toDependencyData2(scope, it) })
|
||||
}
|
||||
|
||||
val OPTIONAL_FILTER = { dep: IClasspathDependency -> ! dep.optional }
|
||||
|
||||
fun compileDependenciesGraph(project: Project, name: String): List<DependencyData> {
|
||||
val depLambda = IClasspathDependency::directDependencies
|
||||
val result =
|
||||
(DynamicGraph.Companion.transitiveClosureGraph(pluginDependencies, depLambda) +
|
||||
DynamicGraph.Companion.transitiveClosureGraph(project.compileDependencies, depLambda) +
|
||||
DynamicGraph.Companion.transitiveClosureGraph(project.compileProvidedDependencies, depLambda))
|
||||
(DynamicGraph.Companion.transitiveClosureGraph(pluginDependencies, depLambda, OPTIONAL_FILTER) +
|
||||
DynamicGraph.Companion.transitiveClosureGraph(project.compileDependencies, depLambda,
|
||||
OPTIONAL_FILTER) +
|
||||
DynamicGraph.Companion.transitiveClosureGraph(project.compileProvidedDependencies, depLambda,
|
||||
OPTIONAL_FILTER))
|
||||
.map { toDependencyData2("compile", it)}
|
||||
|
||||
fun mapOfLatestVersions(l: List<DependencyData>) : Map<String, String> {
|
||||
fun p(l: List<DependencyData>, latestVersions: HashMap<String, String>) {
|
||||
fun p(l: List<DependencyData>, latestVersions: java.util.HashMap<String, String>) {
|
||||
l.forEach {
|
||||
if (it.id.contains("squareup:okio")) {
|
||||
println("DONOTCOMMIT")
|
||||
}
|
||||
val mid = MavenId.create(it.id)
|
||||
val shortId = mid.artifactId + ":" + mid.artifactId
|
||||
val currentLatest = latestVersions[shortId]
|
||||
|
@ -114,7 +115,7 @@ class RemoteDependencyData @Inject constructor(val executors: KobaltExecutors, v
|
|||
|
||||
fun testDependenciesGraph(project: Project, name: String): List<DependencyData> {
|
||||
val depLambda = { dep : IClasspathDependency -> dep.directDependencies() }
|
||||
return DynamicGraph.Companion.transitiveClosureGraph(project.testDependencies, depLambda)
|
||||
return DynamicGraph.Companion.transitiveClosureGraph(project.testDependencies, depLambda, OPTIONAL_FILTER)
|
||||
.map { toDependencyData2("testCompile", it)}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue