mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
IIncrementalTaskContributor.
This commit is contained in:
parent
40d251e08d
commit
182ee52be2
5 changed files with 57 additions and 2 deletions
|
@ -3,6 +3,7 @@ package com.beust.kobalt
|
|||
import com.beust.kobalt.api.*
|
||||
import com.beust.kobalt.api.annotation.IncrementalTask
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
import com.beust.kobalt.internal.IncrementalManager
|
||||
import com.beust.kobalt.internal.PluginInfo
|
||||
import com.beust.kobalt.internal.TaskManager
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
|
@ -28,6 +29,7 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManage
|
|||
val localRepo: LocalRepo,
|
||||
val executors: KobaltExecutors,
|
||||
val pluginInfo: PluginInfo,
|
||||
val incrementalManagerFactory: IncrementalManager.IFactory,
|
||||
val taskManager: TaskManager) {
|
||||
|
||||
companion object {
|
||||
|
@ -84,6 +86,23 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManage
|
|||
}
|
||||
}
|
||||
|
||||
// ... and from the incremental task contributors
|
||||
val incrementalManager = incrementalManagerFactory.create()
|
||||
context.pluginInfo.incrementalTaskContributors.forEach {
|
||||
projects.forEach { project ->
|
||||
it.incrementalTasksFor(project, context).forEach {
|
||||
// Convert the closure (Project) -> IncrementalTaskInfo to (Project) -> TaskResult
|
||||
// and create a DynamicTask out of it
|
||||
val closure =
|
||||
incrementalManager.toIncrementalTaskClosure(it.name, it.incrementalClosure, Variant())
|
||||
val task = DynamicTask(it.plugin, it.name, it.doc, it.group, it.project, it.dependsOn,
|
||||
it.reverseDependsOn, it.runBefore, it.runAfter, it.alwaysRunAfter,
|
||||
closure)
|
||||
taskManager.dynamicTasks.add(task)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now that we have collected all static and dynamic tasks, turn them all into plug-in tasks
|
||||
taskManager.computePluginTasks(projects)
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package com.beust.kobalt.api
|
||||
|
||||
import com.beust.kobalt.IncrementalTaskInfo
|
||||
|
||||
/**
|
||||
* Plug-ins that need to add incremental dynamic tasks (tasks that are not methods annotated with @Task) need
|
||||
* to implement this interface.
|
||||
*/
|
||||
interface IIncrementalTaskContributor : IContributor {
|
||||
fun incrementalTasksFor(project: Project, context: KobaltContext) : List<IncrementalDynamicTask>
|
||||
}
|
||||
|
||||
class IncrementalDynamicTask(val context: KobaltContext,
|
||||
val plugin: IPlugin,
|
||||
val name: String,
|
||||
val doc: String,
|
||||
val group: String,
|
||||
val project: Project,
|
||||
val dependsOn: List<String> = listOf<String>(),
|
||||
val reverseDependsOn: List<String> = listOf<String>(),
|
||||
val runBefore: List<String> = listOf<String>(),
|
||||
val runAfter: List<String> = listOf<String>(),
|
||||
val alwaysRunAfter: List<String> = listOf<String>(),
|
||||
val incrementalClosure: (Project) -> IncrementalTaskInfo) {
|
||||
override fun toString() = "[IncrementalDynamicTask $name dependsOn=$dependsOn reverseDependsOn=$reverseDependsOn]"
|
||||
}
|
||||
|
||||
|
|
@ -3,6 +3,7 @@ package com.beust.kobalt.api
|
|||
import com.beust.kobalt.Args
|
||||
import com.beust.kobalt.Plugins
|
||||
import com.beust.kobalt.Variant
|
||||
import com.beust.kobalt.internal.IncrementalManager
|
||||
import com.beust.kobalt.internal.KobaltSettings
|
||||
import com.beust.kobalt.internal.PluginInfo
|
||||
import com.beust.kobalt.maven.DependencyManager
|
||||
|
@ -35,6 +36,7 @@ class KobaltContext(val args: Args) {
|
|||
lateinit var dependencyManager: DependencyManager
|
||||
lateinit var executors: KobaltExecutors
|
||||
lateinit var settings: KobaltSettings
|
||||
lateinit var incrementalManager: IncrementalManager
|
||||
}
|
||||
|
||||
class InternalContext {
|
||||
|
|
|
@ -94,6 +94,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
|||
val buildConfigContributors = arrayListOf<IBuildConfigContributor>()
|
||||
val mavenIdInterceptors = arrayListOf<IMavenIdInterceptor>()
|
||||
val jvmFlagContributors = arrayListOf<IJvmFlagContributor>()
|
||||
val incrementalTaskContributors = arrayListOf<IIncrementalTaskContributor>()
|
||||
|
||||
// Note: intentionally repeating them here even though they are defined by our base class so
|
||||
// that this class always contains the full list of contributors and interceptors
|
||||
|
@ -208,6 +209,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
|||
if (this is ITestJvmFlagContributor) testJvmFlagContributors.add(this)
|
||||
if (this is ITestJvmFlagInterceptor) testJvmFlagInterceptors.add(this)
|
||||
if (this is IJvmFlagContributor) jvmFlagContributors.add(this)
|
||||
if (this is IIncrementalTaskContributor) incrementalTaskContributors.add(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +221,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
|||
runnerContributors, testRunnerContributors, classpathInterceptors,
|
||||
compilerContributors, docContributors, sourceDirContributors,
|
||||
testSourceDirContributors, buildConfigFieldContributors,
|
||||
taskContributors, assemblyContributors,
|
||||
taskContributors, incrementalTaskContributors, assemblyContributors,
|
||||
incrementalAssemblyContributors, testJvmFlagInterceptors,
|
||||
jvmFlagContributors
|
||||
).forEach {
|
||||
|
@ -252,6 +254,7 @@ class PluginInfo(val xml: KobaltPluginXml, val pluginClassLoader: ClassLoader?,
|
|||
sourceDirContributors.addAll(pluginInfo.sourceDirContributors)
|
||||
buildConfigFieldContributors.addAll(pluginInfo.buildConfigFieldContributors)
|
||||
taskContributors.addAll(pluginInfo.taskContributors)
|
||||
incrementalTaskContributors.addAll(pluginInfo.incrementalTaskContributors)
|
||||
testSourceDirContributors.addAll(pluginInfo.testSourceDirContributors)
|
||||
mavenIdInterceptors.addAll(pluginInfo.mavenIdInterceptors)
|
||||
buildConfigContributors.addAll(pluginInfo.buildConfigContributors)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue