mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Actual transitive closure.
This commit is contained in:
parent
c8be1d8dd4
commit
21e2d89fdc
1 changed files with 20 additions and 5 deletions
|
@ -151,14 +151,29 @@ class TaskManager @Inject constructor(val args: Args,
|
|||
projects.forEach { put(it.name, it)}
|
||||
}
|
||||
val result = ArrayList(taskNames)
|
||||
taskNames.forEach { taskName ->
|
||||
val toProcess = ArrayList(taskNames)
|
||||
val newToProcess = arrayListOf<String>()
|
||||
val seen = hashSetOf<String>()
|
||||
var stop = false
|
||||
while (! stop) {
|
||||
toProcess.forEach { taskName ->
|
||||
val ti = TaskInfo(taskName)
|
||||
projectMap[ti.project]?.let { project ->
|
||||
project.projectExtra.dependsOn.forEach { dp ->
|
||||
result.add(TaskInfo(dp.projectName, ti.taskName).id)
|
||||
val newTask = TaskInfo(dp.projectName, ti.taskName).id
|
||||
result.add(newTask)
|
||||
if (! seen.contains(newTask)) {
|
||||
newToProcess.add(newTask)
|
||||
seen.add(newTask)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stop = newToProcess.isEmpty()
|
||||
toProcess.clear()
|
||||
toProcess.addAll(newToProcess)
|
||||
newToProcess.clear()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue