mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Fix free task bug.
This commit is contained in:
parent
36b41c11e9
commit
4b042fa94f
3 changed files with 19 additions and 16 deletions
|
@ -19,13 +19,13 @@ public interface Plugin {
|
||||||
|
|
||||||
fun addStaticTask(annotation: Task, project: Project, task: (Project) -> TaskResult) {
|
fun addStaticTask(annotation: Task, project: Project, task: (Project) -> TaskResult) {
|
||||||
addTask(project, annotation.name, annotation.description, annotation.runBefore.toList(),
|
addTask(project, annotation.name, annotation.description, annotation.runBefore.toList(),
|
||||||
annotation.runAfter.toList(), annotation.wrapAfter.toList(), task)
|
annotation.runAfter.toList(), annotation.alwaysRunAfter.toList(), task)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addTask(project: Project, name: String, description: String = "",
|
fun addTask(project: Project, name: String, description: String = "",
|
||||||
runBefore: List<String> = arrayListOf<String>(),
|
runBefore: List<String> = arrayListOf<String>(),
|
||||||
runAfter: List<String> = arrayListOf<String>(),
|
runAfter: List<String> = arrayListOf<String>(),
|
||||||
wrapAfter: List<String> = arrayListOf<String>(),
|
alwaysRunAfter: List<String> = arrayListOf<String>(),
|
||||||
task: (Project) -> TaskResult) {
|
task: (Project) -> TaskResult) {
|
||||||
tasks.add(
|
tasks.add(
|
||||||
object : BasePluginTask(this, name, description, project) {
|
object : BasePluginTask(this, name, description, project) {
|
||||||
|
@ -36,7 +36,7 @@ public interface Plugin {
|
||||||
})
|
})
|
||||||
runBefore.forEach { taskManager.runBefore(it, name) }
|
runBefore.forEach { taskManager.runBefore(it, name) }
|
||||||
runAfter.forEach { taskManager.runBefore(name, it) }
|
runAfter.forEach { taskManager.runBefore(name, it) }
|
||||||
wrapAfter.forEach { taskManager.wrapAfter(it, name)}
|
alwaysRunAfter.forEach { taskManager.alwaysRunAfter(it, name)}
|
||||||
}
|
}
|
||||||
|
|
||||||
var taskManager : TaskManager
|
var taskManager : TaskManager
|
||||||
|
|
|
@ -7,6 +7,7 @@ annotation class Directive
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
annotation class Task(val name: String,
|
annotation class Task(val name: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
|
|
||||||
/** Tasks that this task depends on */
|
/** Tasks that this task depends on */
|
||||||
val runBefore: Array<String> = arrayOf(),
|
val runBefore: Array<String> = arrayOf(),
|
||||||
|
|
||||||
|
@ -14,5 +15,5 @@ annotation class Task(val name: String,
|
||||||
val runAfter: Array<String> = arrayOf(),
|
val runAfter: Array<String> = arrayOf(),
|
||||||
|
|
||||||
/** Tasks that this task will always run after */
|
/** Tasks that this task will always run after */
|
||||||
val wrapAfter: Array<String> = arrayOf()
|
val alwaysRunAfter: Array<String> = arrayOf()
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,7 @@ import javax.inject.Singleton
|
||||||
public class TaskManager @Inject constructor(val plugins: Plugins, val args: Args) : KobaltLogger {
|
public class TaskManager @Inject constructor(val plugins: Plugins, val args: Args) : KobaltLogger {
|
||||||
private val runBefore = TreeMultimap.create<String, String>()
|
private val runBefore = TreeMultimap.create<String, String>()
|
||||||
private val runAfter = TreeMultimap.create<String, String>()
|
private val runAfter = TreeMultimap.create<String, String>()
|
||||||
private val wrapAfter = TreeMultimap.create<String, String>()
|
private val alwaysRunAfter = TreeMultimap.create<String, String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by plugins to indicate task dependencies defined at runtime. Keys depend on values.
|
* Called by plugins to indicate task dependencies defined at runtime. Keys depend on values.
|
||||||
|
@ -32,8 +32,8 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
|
||||||
runAfter.put(task1, task2)
|
runAfter.put(task1, task2)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun wrapAfter(task1: String, task2: String) {
|
fun alwaysRunAfter(task1: String, task2: String) {
|
||||||
wrapAfter.put(task1, task2)
|
alwaysRunAfter.put(task1, task2)
|
||||||
}
|
}
|
||||||
|
|
||||||
data class TaskInfo(val id: String) {
|
data class TaskInfo(val id: String) {
|
||||||
|
@ -62,8 +62,6 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
|
||||||
log(1, "")
|
log(1, "")
|
||||||
|
|
||||||
targets.forEach { target ->
|
targets.forEach { target ->
|
||||||
tasksAlreadyRun.add(TaskInfo(projectName, target).id)
|
|
||||||
|
|
||||||
val graph = DynamicGraph<PluginTask>()
|
val graph = DynamicGraph<PluginTask>()
|
||||||
|
|
||||||
val ti = TaskInfo(target)
|
val ti = TaskInfo(target)
|
||||||
|
@ -71,20 +69,24 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
|
||||||
val task = tasksByNames.get(ti.task)
|
val task = tasksByNames.get(ti.task)
|
||||||
if (task != null && task.plugin.accept(project)) {
|
if (task != null && task.plugin.accept(project)) {
|
||||||
//
|
//
|
||||||
// Add free tasks as nodes to the graph
|
// If the current target is free, add it as a single node to the graph
|
||||||
//
|
//
|
||||||
calculateFreeTasks(tasksByNames).forEach {
|
val currentFreeTask = calculateFreeTasks(tasksByNames).filter { it.name == target }
|
||||||
val thisTaskInfo = TaskInfo(projectName, it.name)
|
if (currentFreeTask.size() == 1) {
|
||||||
if (! tasksAlreadyRun.contains(thisTaskInfo.id)) {
|
currentFreeTask.get(0).let {
|
||||||
graph.addNode(it)
|
val thisTaskInfo = TaskInfo(projectName, it.name)
|
||||||
tasksAlreadyRun.add(thisTaskInfo.id)
|
if (! tasksAlreadyRun.contains(thisTaskInfo.id)) {
|
||||||
|
graph.addNode(it)
|
||||||
|
tasksAlreadyRun.add(thisTaskInfo.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add the transitive closure of the current task as edges to the graph
|
// 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)
|
||||||
|
transitiveClosure.forEach { pluginTask ->
|
||||||
val rb = runBefore.get(pluginTask.name)
|
val rb = runBefore.get(pluginTask.name)
|
||||||
rb.forEach {
|
rb.forEach {
|
||||||
val to = tasksByNames.get(it)
|
val to = tasksByNames.get(it)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue