Skip to content

Commit

Permalink
Add composite build parent tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatBeresnev committed Oct 19, 2023
1 parent e150c5f commit d075fb4
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
22 changes: 22 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {
id("org.jetbrains.conventions.base")
id("org.jetbrains.conventions.dokka")

// TODO [structure-refactoring] enable
// alias(libs.plugins.kotlinx.binaryCompatibilityValidator)
alias(libs.plugins.nexusPublish)
}
Expand Down Expand Up @@ -38,6 +39,27 @@ val dokkaPublish by tasks.registering {
}
}

addDependencyOnSameTaskOfIncludedBuilds("assemble")
addDependencyOnSameTaskOfIncludedBuilds("build")
addDependencyOnSameTaskOfIncludedBuilds("clean")
addDependencyOnSameTaskOfIncludedBuilds("check")

registerParentTaskOfIncludedBuilds("test", groupName = "verification")

fun addDependencyOnSameTaskOfIncludedBuilds(existingTaskName: String) {
tasks.named(existingTaskName) {
dependsOn(gradle.includedBuilds.map { it.task(":$existingTaskName") })
}
}

fun registerParentTaskOfIncludedBuilds(taskName: String, groupName: String) {
tasks.register(taskName) {
group = groupName
description = "Runs $taskName tasks of all included builds"
dependsOn(gradle.includedBuilds.map { it.task(":$taskName") })
}
}

//apiValidation {
// // note that subprojects are ignored by their name, not their path https://github.com/Kotlin/binary-compatibility-validator/issues/16
// ignoredProjects += setOf(
Expand Down
30 changes: 30 additions & 0 deletions dokka-subprojects/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,33 @@ val dokka_version: String by project

group = "org.jetbrains.dokka"
version = dokka_version

addDependencyToSubprojectTasks("assemble")
addDependencyToSubprojectTasks("build")
addDependencyToSubprojectTasks("clean")
addDependencyToSubprojectTasks("check")

registerParentTask("test", groupName = "verification")

fun addDependencyToSubprojectTasks(existingTaskName: String) {
tasks.named(existingTaskName) {
val subprojectTasks = subprojects
.filter { it.getTasksByName(existingTaskName, false).isNotEmpty() }
.map { ":${it.name}:$existingTaskName" }

dependsOn(subprojectTasks)
}
}

fun registerParentTask(taskName: String, groupName: String) {
tasks.register(taskName) {
group = groupName
description = "Runs $taskName tasks of all subprojects"

val subprojectTasks = subprojects
.filter { it.getTasksByName(taskName, false).isNotEmpty() }
.map { ":${it.name}:$taskName" }

dependsOn(subprojectTasks)
}
}

0 comments on commit d075fb4

Please sign in to comment.