mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix dependencies.
This commit is contained in:
parent
22315abe08
commit
cf0620d973
2 changed files with 30 additions and 30 deletions
|
@ -77,21 +77,21 @@ abstract class BaseProjectRunner {
|
||||||
// the end of the loop, @param[toProcess] is cleared and all the new nodes get added to it. Then we loop.
|
// the end of the loop, @param[toProcess] is cleared and all the new nodes get added to it. Then we loop.
|
||||||
val toProcess = ArrayList(taskInfos)
|
val toProcess = ArrayList(taskInfos)
|
||||||
|
|
||||||
while (toProcess.size > 0) {
|
/**
|
||||||
|
* Add an edge from @param from to all its tasks.
|
||||||
/**
|
*/
|
||||||
* Add an edge from @param from to all its tasks.
|
fun addEdge(result: DynamicGraph<T>, from: String, to: String, newToProcess: ArrayList<T>, text: String) {
|
||||||
*/
|
val froms = nodeMap[from]
|
||||||
fun addEdge(result: DynamicGraph<T>, from: String, to: String, newToProcess: ArrayList<T>, text: String) {
|
froms.forEach { f: T ->
|
||||||
val froms = nodeMap[from]
|
nodeMap[to].forEach { t: T ->
|
||||||
froms.forEach { f: T ->
|
kobaltLog(LOG_LEVEL, " Adding edge ($text) $f -> $t")
|
||||||
nodeMap[to].forEach { t: T ->
|
result.addEdge(f, t)
|
||||||
kobaltLog(LOG_LEVEL, " Adding edge ($text) $f -> $t")
|
newToProcess.add(t)
|
||||||
result.addEdge(f, t)
|
|
||||||
newToProcess.add(t)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (toProcess.size > 0) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whenever a task is added to the graph, we also add its alwaysRunAfter tasks.
|
* Whenever a task is added to the graph, we also add its alwaysRunAfter tasks.
|
||||||
|
@ -144,22 +144,6 @@ abstract class BaseProjectRunner {
|
||||||
addEdge(result, taskName, to, newToProcess, "dependsOn")
|
addEdge(result, taskName, to, newToProcess, "dependsOn")
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// runBefore and runAfter (task ordering) are only considered for explicit tasks (tasks that were
|
|
||||||
// explicitly requested by the user)
|
|
||||||
//
|
|
||||||
passedTasks.map { it.taskName }.let { taskNames ->
|
|
||||||
runBefore[taskName].forEach { from ->
|
|
||||||
if (taskNames.contains(from)) {
|
|
||||||
addEdge(result, from, taskName, newToProcess, "runBefore")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
runAfter[taskName].forEach { to ->
|
|
||||||
if (taskNames.contains(to)) {
|
|
||||||
addEdge(result, taskName, to, newToProcess, "runAfter")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
seen.add(taskName)
|
seen.add(taskName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +153,22 @@ abstract class BaseProjectRunner {
|
||||||
toProcess.addAll(newToProcess.filter { !seen.contains(toName(it)) }.map { TaskManager.TaskInfo(toName(it)) })
|
toProcess.addAll(newToProcess.filter { !seen.contains(toName(it)) }.map { TaskManager.TaskInfo(toName(it)) })
|
||||||
newToProcess.clear()
|
newToProcess.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// runBefore and runAfter (task ordering) are only considered for explicit tasks (tasks that were
|
||||||
|
// explicitly requested by the user)
|
||||||
|
//
|
||||||
|
val values = result.nodes.map { TaskManager.TaskInfo(it.value.toString()).taskName }
|
||||||
|
values.forEach { taskName ->
|
||||||
|
runBefore[taskName].forEach { from ->
|
||||||
|
addEdge(result, from, taskName, newToProcess, "runBefore")
|
||||||
|
}
|
||||||
|
runAfter[taskName].forEach { to ->
|
||||||
|
addEdge(result, taskName, to, newToProcess, "runAfter")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class TaskManagerTest : BaseTest() {
|
||||||
runAfter = TreeMultimap.create<String, String>().apply {
|
runAfter = TreeMultimap.create<String, String>().apply {
|
||||||
put("compile", "example")
|
put("compile", "example")
|
||||||
}).let { runTasks ->
|
}).let { runTasks ->
|
||||||
assertThat(runTasks).isEqualTo(listOf("clean", "compile"))
|
assertThat(runTasks).isEqualTo(listOf("clean", "example", "compile"))
|
||||||
}
|
}
|
||||||
|
|
||||||
runTasks(listOf("compile"),
|
runTasks(listOf("compile"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue