mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57:12 -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) {
|
||||
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 = "",
|
||||
runBefore: List<String> = arrayListOf<String>(),
|
||||
runAfter: List<String> = arrayListOf<String>(),
|
||||
wrapAfter: List<String> = arrayListOf<String>(),
|
||||
task: (Project) -> TaskResult) {
|
||||
tasks.add(
|
||||
object : BasePluginTask(this, name, description, project) {
|
||||
|
@ -35,6 +36,7 @@ public interface Plugin {
|
|||
})
|
||||
runBefore.forEach { taskManager.runBefore(it, name) }
|
||||
runAfter.forEach { taskManager.runBefore(name, it) }
|
||||
wrapAfter.forEach { taskManager.wrapAfter(it, name)}
|
||||
}
|
||||
|
||||
var taskManager : TaskManager
|
||||
|
|
|
@ -8,4 +8,6 @@ annotation class Directive
|
|||
annotation class Task(val name: String,
|
||||
val description: String,
|
||||
val runBefore: Array<String> = arrayOf(),
|
||||
val runAfter: Array<String> = arrayOf())
|
||||
val runAfter: Array<String> = arrayOf(),
|
||||
val wrapAfter: Array<String> = arrayOf()
|
||||
)
|
||||
|
|
|
@ -15,7 +15,8 @@ import javax.inject.Singleton
|
|||
@Singleton
|
||||
public class TaskManager @Inject constructor(val plugins: Plugins, val args: Args) : KobaltLogger {
|
||||
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.
|
||||
|
@ -29,6 +30,10 @@ public class TaskManager @Inject constructor(val plugins: Plugins, val args: Arg
|
|||
runAfter.put(task1, task2)
|
||||
}
|
||||
|
||||
fun wrapAfter(task1: String, task2: String) {
|
||||
wrapAfter.put(task1, task2)
|
||||
}
|
||||
|
||||
class TaskInfo(val id: String) {
|
||||
val project: String?
|
||||
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
|
||||
}
|
||||
if (actualTarget != null) {
|
||||
wrapAfter.get(actualTarget).let {
|
||||
newToProcess.addAll(it)
|
||||
}
|
||||
transitiveClosure.add(actualTarget)
|
||||
val tasks = tasksByNames.get(actualTarget)
|
||||
if (tasks.isEmpty()) {
|
||||
|
|
|
@ -32,14 +32,6 @@ public class KotlinPlugin @Inject constructor(
|
|||
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 {
|
||||
public const val TASK_COMPILE: String = "compile"
|
||||
public const val TASK_COMPILE_TEST: String = "compileTest"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue