From be31f19145a096198df5f371118961f202126eb0 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Thu, 14 Nov 2024 19:04:20 +0100 Subject: [PATCH] [Gradle] Fix documentation publishing to Kotlinlang The Template was applied only to the final aggregate, but not to the partial tasks. ^KT-73128 Fixed --- .../tools/gradle/documentation/Readme.md | 2 +- .../gradle/documentation/build.gradle.kts | 6 ++---- .../PluginsApiDocumentationExtension.kt | 8 +++++++- .../gradle-plugins-documentation.gradle.kts | 20 ++++++++++++++----- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/libraries/tools/gradle/documentation/Readme.md b/libraries/tools/gradle/documentation/Readme.md index ca0937e0ddeed..548e1a008462e 100644 --- a/libraries/tools/gradle/documentation/Readme.md +++ b/libraries/tools/gradle/documentation/Readme.md @@ -4,7 +4,7 @@ This project assembles API reference for Kotlin Gradle plugins to publish it to ### Configuration -- `build/templates` dir is used for Kotlinlang website templates. Currently, they should be put there manually. +- `/build/api-reference/templates/` dir is used for Kotlinlang website templates. Currently, they should be put there manually. - `build/documentation/kotlinlangOld` directory is used for previously generated documentation. Inside the structure of subdirectories should follow [this specification](https://github.com/Kotlin/dokka/tree/1.9.20/dokka-subprojects/plugin-versioning#directory-structure). diff --git a/libraries/tools/gradle/documentation/build.gradle.kts b/libraries/tools/gradle/documentation/build.gradle.kts index 1433ec0e3f3a6..64b57ca0b9b7e 100644 --- a/libraries/tools/gradle/documentation/build.gradle.kts +++ b/libraries/tools/gradle/documentation/build.gradle.kts @@ -8,8 +8,6 @@ pluginsApiDocumentation { templatesArchiveUrl = "https://github.com/JetBrains/kotlin-web-site/archive/refs/heads/master.zip" templatesArchiveSubDirectoryPattern = "kotlin-web-site-master/dokka-templates/**" templatesArchivePrefixToRemove = "kotlin-web-site-master/dokka-templates/" - gradlePluginsProjects = setOf( - project(":kotlin-gradle-plugin-api"), - project(":compose-compiler-gradle-plugin") - ) + addGradlePluginProject(project(":kotlin-gradle-plugin-api")) + addGradlePluginProject(project(":compose-compiler-gradle-plugin")) } \ No newline at end of file diff --git a/repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/PluginsApiDocumentationExtension.kt b/repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/PluginsApiDocumentationExtension.kt index afe9d6ea2527f..c9f6118721d14 100644 --- a/repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/PluginsApiDocumentationExtension.kt +++ b/repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/PluginsApiDocumentationExtension.kt @@ -12,11 +12,17 @@ import javax.inject.Inject abstract class PluginsApiDocumentationExtension @Inject constructor( objectFactory: ObjectFactory, + private val childProjectConfiguration: (Project) -> Unit ) { abstract val documentationOutput: DirectoryProperty abstract val documentationOldVersions: DirectoryProperty abstract val templatesArchiveUrl: Property val templatesArchiveSubDirectoryPattern: Property = objectFactory.property(String::class.java).convention("") val templatesArchivePrefixToRemove: Property = objectFactory.property(String::class.java).convention("") - abstract val gradlePluginsProjects: SetProperty + internal abstract val gradlePluginsProjects: SetProperty + + fun addGradlePluginProject(project: Project) { + gradlePluginsProjects.add(project) + childProjectConfiguration(project) + } } \ No newline at end of file diff --git a/repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/gradle-plugins-documentation.gradle.kts b/repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/gradle-plugins-documentation.gradle.kts index 4d0dfd92744d7..4367ca41ef7ba 100644 --- a/repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/gradle-plugins-documentation.gradle.kts +++ b/repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/gradle-plugins-documentation.gradle.kts @@ -1,13 +1,26 @@ import de.undercouch.gradle.tasks.download.Download import gradle.publishGradlePluginsJavadoc import org.jetbrains.dokka.gradle.DokkaMultiModuleFileLayout +import org.jetbrains.dokka.gradle.DokkaTaskPartial plugins { id("org.jetbrains.dokka") base } -val documentationExtension = extensions.create("pluginsApiDocumentation") +val templateConfig = Pair( + "org.jetbrains.dokka.base.DokkaBase", + "{ \"templatesDir\": \"${project.rootDir.resolve("build/api-reference/templates").also { it.mkdirs() }}\" }" +) + +val documentationExtension = extensions.create( + "pluginsApiDocumentation", + { project: Project -> + project.tasks.withType().configureEach { + pluginsMapConfiguration.put(templateConfig.first, templateConfig.second) + } + } +) dependencies { dokkaPlugin(versionCatalogs.named("libs").findLibrary("dokka-versioningPlugin").get()) @@ -67,10 +80,7 @@ tasks.register("dokkaKotlinlang ) dependsOn(unzipTemplates) - pluginsMapConfiguration.put( - "org.jetbrains.dokka.base.DokkaBase", - "{ \"templatesDir\": \"${unzipTemplates.map { it.destinationDir }.get().also { it.mkdirs() }}\" }" - ) + pluginsMapConfiguration.put(templateConfig.first, templateConfig.second) // Documentation: https://github.com/Kotlin/dokka/tree/1.9.20/dokka-subprojects/plugin-versioning pluginsMapConfiguration.put(