mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Fix tasks.
This commit is contained in:
parent
371929f754
commit
fc58dd208c
8 changed files with 17 additions and 15 deletions
|
@ -90,10 +90,11 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
|||
currentClass = currentClass.superclass
|
||||
}
|
||||
|
||||
// Collect all the tasks from the task contributors
|
||||
context.pluginInfo.taskContributors.forEach {
|
||||
taskManager.dynamicTasks.addAll(it.tasksFor(context).map { TaskManager.PluginDynamicTask(plugin, it) })
|
||||
}
|
||||
}
|
||||
|
||||
// Collect all the tasks from the task contributors
|
||||
context.pluginInfo.taskContributors.forEach {
|
||||
taskManager.dynamicTasks.addAll(it.tasksFor(context).map { TaskManager.PluginDynamicTask(it.plugin, it) })
|
||||
}
|
||||
|
||||
// Now that we have collected all static and dynamic tasks, turn them all into plug-in tasks
|
||||
|
|
|
@ -10,7 +10,7 @@ interface ITaskContributor : IContributor {
|
|||
fun tasksFor(context: KobaltContext) : List<DynamicTask>
|
||||
}
|
||||
|
||||
class DynamicTask(val name: String, val description: String = "",
|
||||
class DynamicTask(val plugin: IPlugin, val name: String, val description: String = "",
|
||||
val runBefore: List<String> = listOf<String>(),
|
||||
val runAfter: List<String> = listOf<String>(),
|
||||
val alwaysRunAfter: List<String> = listOf<String>(),
|
||||
|
|
|
@ -14,13 +14,13 @@ class TaskContributor : ITaskContributor {
|
|||
* Register dynamic tasks corresponding to the variants found in the project,e.g. assembleDevDebug,
|
||||
* assembleDevRelease, etc...
|
||||
*/
|
||||
fun addVariantTasks(project: Project, context: KobaltContext, taskName: String,
|
||||
fun addVariantTasks(plugin: IPlugin, project: Project, context: KobaltContext, taskName: String,
|
||||
runBefore : List<String> = emptyList(),
|
||||
runAfter : List<String> = emptyList(),
|
||||
runTask: (Project) -> TaskResult) {
|
||||
Variant.allVariants(project).forEach { variant ->
|
||||
val variantTaskName = variant.toTask(taskName)
|
||||
dynamicTasks.add(DynamicTask(variantTaskName, variantTaskName,
|
||||
dynamicTasks.add(DynamicTask(plugin, variantTaskName, variantTaskName,
|
||||
runBefore = runBefore.map { variant.toTask(it) },
|
||||
runAfter = runAfter.map { variant.toTask(it) },
|
||||
closure = { p: Project ->
|
||||
|
|
|
@ -60,7 +60,7 @@ abstract class JvmCompilerPlugin @Inject constructor(
|
|||
override fun apply(project: Project, context: KobaltContext) {
|
||||
super.apply(project, context)
|
||||
project.projectProperties.put(DEPENDENT_PROJECTS, projects())
|
||||
taskContributor.addVariantTasks(project, context, "compile", runTask = { taskCompile(project) })
|
||||
taskContributor.addVariantTasks(this, project, context, "compile", runTask = { taskCompile(project) })
|
||||
}
|
||||
|
||||
@Task(name = TASK_TEST, description = "Run the tests",
|
||||
|
|
|
@ -137,6 +137,7 @@ class PluginInfo(val xml: KobaltPluginXml, val classLoader: ClassLoader?) {
|
|||
if (this is IRunnerContributor) runnerContributors.add(this)
|
||||
if (this is ISourceDirectoryContributor) sourceDirContributors.add(this)
|
||||
if (this is ISourceDirectoryIncerceptor) sourceDirectoriesInterceptors.add(this)
|
||||
if (this is ITaskContributor) taskContributors.add(this)
|
||||
if (this is ITestRunnerContributor) testRunnerContributors.add(this)
|
||||
|
||||
// Not documented yet
|
||||
|
|
|
@ -42,17 +42,17 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler, v
|
|||
if (accept(project)) {
|
||||
project.compileDependencies.add(FileDependency(androidJar(project).toString()))
|
||||
|
||||
taskContributor.addVariantTasks(project, context, "generateR", runBefore = listOf("compile"),
|
||||
taskContributor.addVariantTasks(this, project, context, "generateR", runBefore = listOf("compile"),
|
||||
runTask = { taskGenerateRFile(project) })
|
||||
taskContributor.addVariantTasks(project, context, "generateDex", runAfter = listOf("compile"),
|
||||
taskContributor.addVariantTasks(this, project, context, "generateDex", runAfter = listOf("compile"),
|
||||
runBefore = listOf("assemble"),
|
||||
runTask = { taskGenerateDex(project) })
|
||||
taskContributor.addVariantTasks(project, context, "signApk", runAfter = listOf("generateDex"),
|
||||
taskContributor.addVariantTasks(this, project, context, "signApk", runAfter = listOf("generateDex"),
|
||||
runBefore = listOf("assemble"),
|
||||
runTask = { taskSignApk(project) })
|
||||
taskContributor.addVariantTasks(project, context, "install", runAfter = listOf("signApk"),
|
||||
taskContributor.addVariantTasks(this, project, context, "install", runAfter = listOf("signApk"),
|
||||
runTask = { taskInstall(project) })
|
||||
taskContributor.addVariantTasks(project, context, "proguard", runBefore = listOf("install"),
|
||||
taskContributor.addVariantTasks(this, project, context, "proguard", runBefore = listOf("install"),
|
||||
runAfter = listOf("compile"),
|
||||
runTask = { taskProguard(project) })
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class ApplicationPlugin @Inject constructor(val executors: KobaltExecutors,
|
|||
|
||||
override fun apply(project: Project, context: KobaltContext) {
|
||||
super.apply(project, context)
|
||||
taskContributor.addVariantTasks(project, context, "run", runAfter = listOf("install"),
|
||||
taskContributor.addVariantTasks(this, project, context, "run", runAfter = listOf("install"),
|
||||
runTask = { taskRun(project) })
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
|||
override fun apply(project: Project, context: KobaltContext) {
|
||||
super.apply(project, context)
|
||||
project.projectProperties.put(LIBS_DIR, libsDir(project))
|
||||
taskContributor.addVariantTasks(project, context, "assemble", runAfter = listOf("compile"),
|
||||
taskContributor.addVariantTasks(this, project, context, "assemble", runAfter = listOf("compile"),
|
||||
runTask = { taskAssemble(project) })
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue