mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
GITHUB-212: Honor project dependencies for single task targets.
Fixes https://github.com/cbeust/kobalt/issues/212
This commit is contained in:
parent
85347e9ac5
commit
a08b8852e8
1 changed files with 24 additions and 1 deletions
|
@ -81,10 +81,11 @@ class TaskManager @Inject constructor(val args: Args,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun runTargets(taskNames: List<String>, projects: List<Project>): RunTargetResult {
|
fun runTargets(passedTaskNames: List<String>, projects: List<Project>): RunTargetResult {
|
||||||
var result = 0
|
var result = 0
|
||||||
val failedProjects = hashSetOf<String>()
|
val failedProjects = hashSetOf<String>()
|
||||||
val messages = Collections.synchronizedList(arrayListOf<String>())
|
val messages = Collections.synchronizedList(arrayListOf<String>())
|
||||||
|
val taskNames = calculateDependentTaskNames(passedTaskNames, projects)
|
||||||
projects.forEach { project ->
|
projects.forEach { project ->
|
||||||
AsciiArt.logBox("Building ${project.name}")
|
AsciiArt.logBox("Building ${project.name}")
|
||||||
|
|
||||||
|
@ -140,6 +141,28 @@ class TaskManager @Inject constructor(val args: Args,
|
||||||
return RunTargetResult(result, messages)
|
return RunTargetResult(result, messages)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the user wants to run a single task on a single project (e.g. "kobalt:assemble"), we need to
|
||||||
|
* see if that project depends on others and if it does, invoke these tasks on all of them. This
|
||||||
|
* function returns all these task names (including dependent).
|
||||||
|
*/
|
||||||
|
private fun calculateDependentTaskNames(taskNames: List<String>, projects: List<Project>): List<String> {
|
||||||
|
val projectMap = hashMapOf<String, Project>().apply {
|
||||||
|
projects.forEach { put(it.name, it)}
|
||||||
|
}
|
||||||
|
val result = ArrayList(taskNames)
|
||||||
|
taskNames.forEach { taskName ->
|
||||||
|
val ti = TaskInfo(taskName)
|
||||||
|
projectMap[ti.project]?.let { project ->
|
||||||
|
project.projectExtra.dependsOn.forEach { dp ->
|
||||||
|
result.add(TaskInfo(dp.projectName, ti.taskName).id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
val LOG_LEVEL = 3
|
val LOG_LEVEL = 3
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue