mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Revamp the graph dependency/ordering logic.
This commit is contained in:
parent
2dd20b43b1
commit
458b40eafc
10 changed files with 128 additions and 175 deletions
|
@ -52,7 +52,7 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<Applica
|
|||
runTask = { taskRun(project) })
|
||||
}
|
||||
|
||||
@Task(name = "run", description = "Run the main class", runAfter = arrayOf("install"))
|
||||
@Task(name = "run", description = "Run the main class", dependsOn = arrayOf("install"))
|
||||
fun taskRun(project: Project): TaskResult {
|
||||
val runContributor = ActorUtils.selectAffinityActor(project, context,
|
||||
context.pluginInfo.runnerContributors)
|
||||
|
|
|
@ -79,7 +79,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
|||
}
|
||||
|
||||
@Task(name = TASK_ASSEMBLE, description = "Package the artifacts",
|
||||
runAfter = arrayOf(JvmCompilerPlugin.TASK_COMPILE))
|
||||
dependsOn = arrayOf(JvmCompilerPlugin.TASK_COMPILE))
|
||||
fun doTaskAssemble(project: Project) : TaskResult {
|
||||
// Incremental assembly contributors
|
||||
context.pluginInfo.incrementalAssemblyContributors.forEach {
|
||||
|
@ -131,7 +131,7 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
|
|||
|
||||
|
||||
@Task(name = PackagingPlugin.TASK_INSTALL, description = "Install the artifacts",
|
||||
runAfter = arrayOf(PackagingPlugin.TASK_ASSEMBLE))
|
||||
dependsOn = arrayOf(PackagingPlugin.TASK_ASSEMBLE))
|
||||
fun taskInstall(project: Project) : TaskResult {
|
||||
val config = configurationFor(project) ?: InstallConfig()
|
||||
val buildDir = project.projectProperties.getString(LIBS_DIR)
|
||||
|
|
|
@ -33,7 +33,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
|
|||
}
|
||||
|
||||
@Suppress("UNUSED_FUNCTION_LITERAL")
|
||||
@Task(name = TASK_GENERATE_POM, description = "Generate the .pom file", runAfter = arrayOf("assemble"))
|
||||
@Task(name = TASK_GENERATE_POM, description = "Generate the .pom file", dependsOn = arrayOf("assemble"))
|
||||
fun taskGeneratePom(project: Project): TaskResult {
|
||||
factory.create(project).generate()
|
||||
return TaskResult()
|
||||
|
@ -56,7 +56,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
|
|||
}
|
||||
|
||||
@Task(name = TASK_UPLOAD_BINTRAY, description = "Upload files to Bintray",
|
||||
runAfter = arrayOf(TASK_GENERATE_POM))
|
||||
dependsOn = arrayOf(TASK_GENERATE_POM))
|
||||
fun taskUploadBintray(project: Project): TaskResult {
|
||||
validateProject(project)
|
||||
return uploadBintray(project)
|
||||
|
@ -100,7 +100,7 @@ public class PublishPlugin @Inject constructor(val files: KFiles, val factory: P
|
|||
}
|
||||
|
||||
@Task(name = TASK_UPLOAD_GITHUB, description = "Upload files to Github",
|
||||
runAfter = arrayOf(TASK_GENERATE_POM))
|
||||
dependsOn = arrayOf(TASK_GENERATE_POM))
|
||||
fun taskUploadGithub(project: Project): TaskResult {
|
||||
validateProject(project)
|
||||
return uploadGithub(project)
|
||||
|
|
|
@ -31,22 +31,24 @@ class TaskManagerTest @Inject constructor(val taskManager: TaskManager) {
|
|||
}
|
||||
|
||||
private fun runTasks(tasks: List<String>) : List<String> {
|
||||
val runBefore = TreeMultimap.create<String, String>().apply {
|
||||
val dependsOn = TreeMultimap.create<String, String>().apply {
|
||||
put("assemble", "compile")
|
||||
}
|
||||
val reverseDependsOn = TreeMultimap.create<String, String>().apply {
|
||||
put("clean", "copyVersion")
|
||||
put("compile", "postCompile")
|
||||
}
|
||||
val runBefore = TreeMultimap.create<String, String>().apply {
|
||||
}
|
||||
val runAfter = TreeMultimap.create<String, String>().apply {
|
||||
put("compile", "clean")
|
||||
put("postCompile", "compile")
|
||||
}
|
||||
val alwaysRunAfter = TreeMultimap.create<String, String>().apply {
|
||||
put("clean", "copyVersion")
|
||||
}
|
||||
val dependencies = TreeMultimap.create<String, String>().apply {
|
||||
listOf("assemble", "compile", "clean", "copyVersion", "postCompile").forEach {
|
||||
put(it, it)
|
||||
}
|
||||
}
|
||||
val graph = taskManager.createGraph("", tasks, dependencies, runBefore, runAfter, alwaysRunAfter,
|
||||
val graph = taskManager.createGraph("", tasks, dependencies, dependsOn, reverseDependsOn, runBefore, runAfter,
|
||||
{ it }, { t -> true })
|
||||
val result = DryRunGraphExecutor(graph).run()
|
||||
return result
|
||||
|
@ -55,11 +57,12 @@ class TaskManagerTest @Inject constructor(val taskManager: TaskManager) {
|
|||
@Test
|
||||
fun graphTest() {
|
||||
KobaltLogger.LOG_LEVEL = 3
|
||||
Assert.assertEquals(runTasks(listOf("compile")), listOf("compile", "postCompile"))
|
||||
Assert.assertEquals(runTasks(listOf("postCompile")), listOf("postCompile"))
|
||||
Assert.assertEquals(runTasks(listOf("compile")), listOf("compile"))
|
||||
Assert.assertEquals(runTasks(listOf("compile", "postCompile")), listOf("compile", "postCompile"))
|
||||
Assert.assertEquals(runTasks(listOf("clean")), listOf("clean", "copyVersion"))
|
||||
Assert.assertEquals(runTasks(listOf("clean", "compile")), listOf("clean", "compile", "copyVersion"))
|
||||
Assert.assertEquals(runTasks(listOf("clean", "compile")), listOf("clean", "compile", "copyVersion",
|
||||
"postCompile"))
|
||||
Assert.assertEquals(runTasks(listOf("assemble")), listOf("compile", "assemble"))
|
||||
Assert.assertEquals(runTasks(listOf("clean", "assemble")), listOf("clean", "compile", "assemble",
|
||||
"copyVersion"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue