diff --git a/build.gradle.kts b/build.gradle.kts index 417c2745b9..a86ec5aa1b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,63 +9,70 @@ plugins { val publishedIncludedBuilds = listOf("runner-cli", "runner-gradle-classic", "runner-maven") val gradlePluginIncludedBuilds = listOf("runner-gradle-classic") -addDependencyOnSameTaskOfIncludedBuilds("assemble") -addDependencyOnSameTaskOfIncludedBuilds("build") -addDependencyOnSameTaskOfIncludedBuilds("clean") -addDependencyOnSameTaskOfIncludedBuilds("check") +addDependencyOnSameTasksOfIncludedBuilds("assemble", "build", "clean", "check") -registerParentTaskOfIncludedBuilds("test", groupName = "verification") - -registerParentTaskOfPublishedIncludedBuilds("apiCheck", groupName = "verification") -registerParentTaskOfPublishedIncludedBuilds("apiDump", groupName = "other") +registerParentGroupTasks("publishing", taskNames = listOf( + "publishAllPublicationsToMavenCentralRepository", + "publishAllPublicationsToProjectLocalRepository", + "publishAllPublicationsToSnapshotRepository", + "publishAllPublicationsToSpaceDevRepository", + "publishAllPublicationsToSpaceTestRepository", + "publishToMavenLocal" +)) { + it.name in publishedIncludedBuilds +} -registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToMavenCentralRepository", groupName = "publication") -registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToProjectLocalRepository", groupName = "publication") -registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToSnapshotRepository", groupName = "publication") -registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToSpaceDevRepository", groupName = "publication") -registerParentTaskOfPublishedIncludedBuilds("publishAllPublicationsToSpaceTestRepository", groupName = "publication") -registerParentTaskOfPublishedIncludedBuilds("publishToMavenLocal", groupName = "publication") +registerParentGroupTasks("verification", taskNames = listOf( + "test", + "apiCheck", + "apiDump" +)) -registerParentTaskOfGradlePluginIncludedBuilds("publishPlugins", groupName = "publication") -registerParentTaskOfGradlePluginIncludedBuilds("validatePlugins", groupName = "plugin development") +registerParentGroupTasks("gradle plugin", taskNames = listOf( + "publishPlugins", + "validatePlugins" +)) { + it.name in gradlePluginIncludedBuilds +} tasks.register("integrationTest") { group = "verification" description = "Runs integration tests of this project. Might take a while and require additional setup." - dependsOn(gradle.includedBuilds.single { it.name == "dokka-integration-tests" }.task(":integrationTest")) -} -fun addDependencyOnSameTaskOfIncludedBuilds(existingTaskName: String, filter: (IncludedBuild) -> Boolean = { true }) { - tasks.named(existingTaskName) { - dependsOn(includedBuildTasks(existingTaskName, filter)) - } + dependsOn(includedBuildTasks("integrationTest") { + it.name == "dokka-integration-tests" + }) } -fun registerParentTaskOfPublishedIncludedBuilds( - taskName: String, - groupName: String -) = registerParentTaskOfIncludedBuilds(taskName, groupName) { - it.name in publishedIncludedBuilds -} - -fun registerParentTaskOfGradlePluginIncludedBuilds( - taskName: String, - groupName: String -) = registerParentTaskOfIncludedBuilds(taskName, groupName) { - it.name in gradlePluginIncludedBuilds +fun addDependencyOnSameTasksOfIncludedBuilds(vararg taskNames: String) { + taskNames.forEach { taskName -> + tasks.named(taskName) { + dependsOn(includedBuildTasks(taskName)) + } + } } -fun registerParentTaskOfIncludedBuilds( - taskName: String, +fun registerParentGroupTasks( groupName: String, - filter: (IncludedBuild) -> Boolean = { true } -) { + taskNames: List, + includedBuildFilter: (IncludedBuild) -> Boolean = { true } +) = taskNames.forEach { taskName -> tasks.register(taskName) { group = groupName - description = "Runs $taskName tasks of included builds" - dependsOn(includedBuildTasks(taskName, filter)) + description = "A parent task that calls tasks with the same name in all subprojects and included builds" + + dependsOn(subprojectTasks(taskName), includedBuildTasks(taskName, includedBuildFilter)) } } -fun includedBuildTasks(taskName: String, filter: (IncludedBuild) -> Boolean): List = - gradle.includedBuilds.filter { it.name != "build-logic" }.filter(filter).map { it.task(":$taskName") } +fun subprojectTasks(taskName: String): List = + subprojects + .filter { it.getTasksByName(taskName, false).isNotEmpty() } + .map { ":${it.path}:$taskName" } + + +fun includedBuildTasks(taskName: String, filter: (IncludedBuild) -> Boolean = { true }): List = + gradle.includedBuilds + .filter { it.name != "build-logic" } + .filter(filter) + .mapNotNull { it.task(":$taskName") } diff --git a/dokka-integration-tests/gradle/build.gradle.kts b/dokka-integration-tests/gradle/build.gradle.kts index f48920f602..3b95cb69df 100644 --- a/dokka-integration-tests/gradle/build.gradle.kts +++ b/dokka-integration-tests/gradle/build.gradle.kts @@ -19,14 +19,10 @@ dependencies { implementation(libs.jsoup) } -val dokkaSubprojects = gradle.includedBuild("dokka") -val gradlePluginClassic = gradle.includedBuild("runner-gradle-classic") +val aggregatingProject = gradle.includedBuild("dokka") tasks.integrationTest { - dependsOn( - dokkaSubprojects.task(":publishToMavenLocal"), - gradlePluginClassic.task(":publishToMavenLocal"), - ) + dependsOn(aggregatingProject.task(":publishToMavenLocal")) environment("DOKKA_VERSION", project.version) diff --git a/dokka-integration-tests/gradle/projects/coroutines/coroutines.diff b/dokka-integration-tests/gradle/projects/coroutines/coroutines.diff index 07acef95af..00dfd99edc 100644 --- a/dokka-integration-tests/gradle/projects/coroutines/coroutines.diff +++ b/dokka-integration-tests/gradle/projects/coroutines/coroutines.diff @@ -52,7 +52,7 @@ index 3d9431be0..b60114bc2 100644 html_version=0.7.2 lincheck_version=2.18.1 -dokka_version=1.8.10 -+dokka_version=1.9.20-SNAPSHOT ++dokka_version=non-existing-sanity-check byte_buddy_version=1.10.9 reactor_version=3.4.1 reactive_streams_version=1.0.3 diff --git a/dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt b/dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt index f2b2857850..14e11a7303 100644 --- a/dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt +++ b/dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/AbstractGradleIntegrationTest.kt @@ -36,7 +36,6 @@ public abstract class AbstractGradleIntegrationTest : AbstractIntegrationTest() .withTestKitDir(File("build", "gradle-test-kit").absoluteFile) .withArguments( listOfNotNull( - "-Pkotlin_version=${buildVersions.kotlinVersion}", "-Pdokka_it_kotlin_version=${buildVersions.kotlinVersion}", buildVersions.androidGradlePluginVersion?.let { androidVersion -> "-Pdokka_it_android_gradle_plugin_version=$androidVersion" diff --git a/dokka-integration-tests/maven/build.gradle.kts b/dokka-integration-tests/maven/build.gradle.kts index aa01b258f7..f0607e61d7 100644 --- a/dokka-integration-tests/maven/build.gradle.kts +++ b/dokka-integration-tests/maven/build.gradle.kts @@ -27,9 +27,9 @@ tasks.integrationTest { val mvn = mavenCliSetup.mvn inputs.file(mvn) - environment("DOKKA_VERSION", project.version) doFirst("workaround for https://github.com/gradle/gradle/issues/24267") { + environment("DOKKA_VERSION", project.version) environment("MVN_BINARY_PATH", mvn.get().asFile.invariantSeparatorsPath) } }