1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-28 09:08:13 -07:00

Add support for wrapAfter().

This commit is contained in:
Cedric Beust 2015-10-09 20:53:47 -07:00
parent f32bfb8c80
commit 81b1d63520

View file

@ -70,10 +70,13 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
if (ti.matches(projectName)) {
val task = tasksByNames.get(ti.task)
if (task != null && task.plugin.accept(project)) {
val allTasks = arrayListOf<PluginTask>()
//
// Add free tasks as nodes to the graph
//
calculateFreeTasks(tasksByNames).forEach {
val freeTasks = calculateFreeTasks(tasksByNames)
allTasks.addAll(freeTasks)
freeTasks.forEach {
val thisTaskInfo = TaskInfo(projectName, it.name)
if (! tasksAlreadyRun.contains(thisTaskInfo.id)) {
graph.addNode(it)
@ -84,7 +87,9 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
//
// Add the transitive closure of the current task as edges to the graph
//
calculateTransitiveClosure(project, tasksByNames, ti, task).forEach { pluginTask ->
val transitiveClosure = calculateTransitiveClosure(project, tasksByNames, ti, task)
allTasks.addAll(transitiveClosure)
transitiveClosure.forEach { pluginTask ->
val rb = runBefore.get(pluginTask.name)
rb.forEach {
val to = tasksByNames.get(it)
@ -99,6 +104,20 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
}
}
}
//
// Now that we have free and non-free nodes in the graph, see if any of them
// has a wrapAfter task and if they do, add the corresponding edge to the graph
//
allTasks.forEach {
val after = wrapAfter.get(it.name)
after.forEach { af ->
val afterTask = tasksByNames.get(af)
if (afterTask != null) {
graph.addEdge(afterTask, it)
}
}
}
}
//
@ -157,14 +176,6 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
log(3, "toProcess size: " + toProcess.size())
toProcess.forEach { target ->
wrapAfter.get(ti.id).let {
val tasks = tasksByNames.get(it)
if (tasks != null) {
tasks.forEach {
newToProcess.add(TaskInfo(project.name!!, task!!.name))
}
}
val currentTask = TaskInfo(project.name!!, target.task)
transitiveClosure.add(tasksByNames.get(currentTask.task)!!)
val task = tasksByNames.get(target.task)