mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 08:38:13 -07:00
wrapAfter()
This commit is contained in:
parent
d2a739a171
commit
4195619a32
4 changed files with 15 additions and 11 deletions
|
@ -19,12 +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(), task)
|
annotation.runAfter.toList(), annotation.wrapAfter.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>(),
|
||||||
task: (Project) -> TaskResult) {
|
task: (Project) -> TaskResult) {
|
||||||
tasks.add(
|
tasks.add(
|
||||||
object : BasePluginTask(this, name, description, project) {
|
object : BasePluginTask(this, name, description, project) {
|
||||||
|
@ -35,6 +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)}
|
||||||
}
|
}
|
||||||
|
|
||||||
var taskManager : TaskManager
|
var taskManager : TaskManager
|
||||||
|
|
|
@ -8,4 +8,6 @@ annotation class Directive
|
||||||
annotation class Task(val name: String,
|
annotation class Task(val name: String,
|
||||||
val description: String,
|
val description: String,
|
||||||
val runBefore: Array<String> = arrayOf(),
|
val runBefore: Array<String> = arrayOf(),
|
||||||
val runAfter: Array<String> = arrayOf())
|
val runAfter: Array<String> = arrayOf(),
|
||||||
|
val wrapAfter: Array<String> = arrayOf()
|
||||||
|
)
|
||||||
|
|
|
@ -16,6 +16,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>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
|
@ -29,6 +30,10 @@ 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) {
|
||||||
|
wrapAfter.put(task1, task2)
|
||||||
|
}
|
||||||
|
|
||||||
class TaskInfo(val id: String) {
|
class TaskInfo(val id: String) {
|
||||||
val project: String?
|
val project: String?
|
||||||
get() = if (id.contains(":")) id.split(":").get(0) else null
|
get() = if (id.contains(":")) id.split(":").get(0) else null
|
||||||
|
@ -101,6 +106,9 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
|
||||||
target
|
target
|
||||||
}
|
}
|
||||||
if (actualTarget != null) {
|
if (actualTarget != null) {
|
||||||
|
wrapAfter.get(actualTarget).let {
|
||||||
|
newToProcess.addAll(it)
|
||||||
|
}
|
||||||
transitiveClosure.add(actualTarget)
|
transitiveClosure.add(actualTarget)
|
||||||
val tasks = tasksByNames.get(actualTarget)
|
val tasks = tasksByNames.get(actualTarget)
|
||||||
if (tasks.isEmpty()) {
|
if (tasks.isEmpty()) {
|
||||||
|
|
|
@ -32,14 +32,6 @@ public class KotlinPlugin @Inject constructor(
|
||||||
Kobalt.registerCompiler(KotlinCompilerInfo())
|
Kobalt.registerCompiler(KotlinCompilerInfo())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun apply(project: Project, context: KobaltContext) {
|
|
||||||
log(1, "ADD SYNTH TASK")
|
|
||||||
// addTask(project, "syntheticTask", "A dynamic task", runBefore = listOf("clean")) { p: Project ->
|
|
||||||
// println("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Synthetic task")
|
|
||||||
// TaskResult()
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
public const val TASK_COMPILE: String = "compile"
|
public const val TASK_COMPILE: String = "compile"
|
||||||
public const val TASK_COMPILE_TEST: String = "compileTest"
|
public const val TASK_COMPILE_TEST: String = "compileTest"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue