-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update task-selector workaround to use task rules
- Workaround for gradle/gradle#22335 - Update tasks: - check runs all validations - test runs apiCheck - introduce 'publishAllPublicationsToRemoteRepositories' lifecycle task
- Loading branch information
Showing
2 changed files
with
133 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,84 @@ | ||
/* | ||
* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
import org.gradle.api.publish.plugins.PublishingPlugin.PUBLISH_TASK_GROUP | ||
import org.gradle.language.base.plugins.LifecycleBasePlugin.VERIFICATION_GROUP | ||
|
||
plugins { | ||
id("dokkabuild.base") | ||
} | ||
|
||
val publishedIncludedBuilds = listOf("runner-cli", "runner-gradle-plugin-classic", "runner-maven-plugin") | ||
val gradlePluginIncludedBuilds = listOf("runner-gradle-plugin-classic") | ||
//region Workarounds for running all tasks in included builds | ||
// https://github.com/gradle/gradle/issues/22335 | ||
// See build-logic/src/main/kotlin/dokkabuild.base.gradle.kts | ||
fun Task.dependsOnIncludedBuildTasks( | ||
taskName: String = name | ||
) { | ||
description = "Lifecycle task that runs '$taskName' in all included builds" | ||
dependsOn("includedBuildTasks_$taskName") | ||
} | ||
|
||
addDependencyOnSameTasksOfIncludedBuilds("assemble", "build", "clean", "check") | ||
val publishPlugins by tasks.registering { | ||
group = "gradle plugin" | ||
dependsOnIncludedBuildTasks() | ||
} | ||
|
||
registerParentGroupTasks("publishing", taskNames = listOf( | ||
"publishAllPublicationsToMavenCentralRepository", | ||
"publishAllPublicationsToProjectLocalRepository", | ||
"publishAllPublicationsToSnapshotRepository", | ||
"publishAllPublicationsToSpaceDevRepository", | ||
"publishAllPublicationsToSpaceTestRepository", | ||
"publishToMavenLocal" | ||
)) { | ||
it.name in publishedIncludedBuilds | ||
val validatePlugins by tasks.registering { | ||
group = "gradle plugin" | ||
dependsOnIncludedBuildTasks() | ||
} | ||
|
||
registerParentGroupTasks("gradle plugin", taskNames = listOf( | ||
"publishPlugins", | ||
"validatePlugins" | ||
)) { | ||
it.name in gradlePluginIncludedBuilds | ||
val apiDump by tasks.registering { | ||
group = "$VERIFICATION_GROUP bcv" | ||
dependsOnIncludedBuildTasks() | ||
} | ||
|
||
registerParentGroupTasks("bcv", taskNames = listOf( | ||
"apiDump", | ||
"apiCheck", | ||
"apiBuild" | ||
)) { | ||
it.name in publishedIncludedBuilds | ||
val apiCheck by tasks.registering { | ||
group = "$VERIFICATION_GROUP bcv" | ||
dependsOnIncludedBuildTasks() | ||
} | ||
|
||
registerParentGroupTasks("verification", taskNames = listOf( | ||
"test" | ||
)) | ||
val test by tasks.registering { | ||
group = VERIFICATION_GROUP | ||
dependsOnIncludedBuildTasks() | ||
dependsOn(apiCheck) | ||
} | ||
|
||
tasks.register("integrationTest") { | ||
group = "verification" | ||
val integrationTest by tasks.registering { | ||
group = VERIFICATION_GROUP | ||
dependsOnIncludedBuildTasks() | ||
description = "Runs integration tests of this project. Might take a while and require additional setup." | ||
|
||
dependsOn(includedBuildTasks("integrationTest") { | ||
it.name == "dokka-integration-tests" | ||
}) | ||
} | ||
|
||
fun addDependencyOnSameTasksOfIncludedBuilds(vararg taskNames: String) { | ||
taskNames.forEach { taskName -> | ||
tasks.named(taskName) { | ||
dependsOn(includedBuildTasks(taskName)) | ||
} | ||
} | ||
val publishAllPublicationsToRemoteRepositories by tasks.registering { | ||
group = PUBLISH_TASK_GROUP | ||
dependsOnIncludedBuildTasks("publishAllPublicationsToMavenCentralRepository") | ||
dependsOnIncludedBuildTasks("publishAllPublicationsToProjectLocalRepository") | ||
dependsOnIncludedBuildTasks("publishAllPublicationsToSnapshotRepository") | ||
dependsOnIncludedBuildTasks("publishAllPublicationsToSpaceDevRepository") | ||
} | ||
|
||
fun registerParentGroupTasks( | ||
groupName: String, | ||
taskNames: List<String>, | ||
includedBuildFilter: (IncludedBuild) -> Boolean = { true } | ||
) = taskNames.forEach { taskName -> | ||
tasks.register(taskName) { | ||
group = groupName | ||
description = "A parent task that calls tasks with the same name in all subprojects and included builds" | ||
|
||
dependsOn(subprojectTasks(taskName), includedBuildTasks(taskName, includedBuildFilter)) | ||
} | ||
val publishAllPublicationsToMavenCentralRepository by tasks.registering { | ||
group = PUBLISH_TASK_GROUP | ||
dependsOnIncludedBuildTasks() | ||
} | ||
|
||
fun subprojectTasks(taskName: String): List<String> = | ||
subprojects | ||
.filter { it.getTasksByName(taskName, false).isNotEmpty() } | ||
.map { ":${it.path}:$taskName" } | ||
|
||
|
||
fun includedBuildTasks(taskName: String, filter: (IncludedBuild) -> Boolean = { true }): List<TaskReference> = | ||
gradle.includedBuilds | ||
.filter { it.name != "build-logic" } | ||
.filter(filter) | ||
.mapNotNull { it.task(":$taskName") } | ||
val publishAllPublicationsToProjectLocalRepository by tasks.registering { | ||
group = PUBLISH_TASK_GROUP | ||
dependsOnIncludedBuildTasks() | ||
} | ||
val publishAllPublicationsToSnapshotRepository by tasks.registering { | ||
group = PUBLISH_TASK_GROUP | ||
dependsOnIncludedBuildTasks() | ||
} | ||
val publishAllPublicationsToSpaceDevRepository by tasks.registering { | ||
group = PUBLISH_TASK_GROUP | ||
dependsOnIncludedBuildTasks() | ||
} | ||
val publishAllPublicationsToSpaceTestRepository by tasks.registering { | ||
group = PUBLISH_TASK_GROUP | ||
dependsOnIncludedBuildTasks() | ||
} | ||
val publishToMavenLocal by tasks.registering { | ||
group = PUBLISH_TASK_GROUP | ||
dependsOnIncludedBuildTasks() | ||
} | ||
//endregion |