From a7dabb638d59fc4ac7ba5aaa6bfed99022d02fa6 Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Wed, 13 Nov 2024 19:29:59 +0100 Subject: [PATCH] [Gradle] Fix templates extraction Previously templates were extracted as-is, but we also need to strip prefix directory for Dokka to detect it. Though I has to disable auto-provisioning of template as it does not work in standalone mode: KT-73082. ^KT-73076 In Progress --- .../tools/gradle/documentation/Readme.md | 16 ++++++++++++++ .../gradle/documentation/build.gradle.kts | 1 + .../PluginsApiDocumentationExtension.kt | 1 + .../gradle-plugins-documentation.gradle.kts | 21 ++++++++++++++++--- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 libraries/tools/gradle/documentation/Readme.md diff --git a/libraries/tools/gradle/documentation/Readme.md b/libraries/tools/gradle/documentation/Readme.md new file mode 100644 index 0000000000000..af4858578eb7a --- /dev/null +++ b/libraries/tools/gradle/documentation/Readme.md @@ -0,0 +1,16 @@ +## Kotlinlang Gradle API reference + +This project assembles API reference for Kotlin Gradle plugins to publish it to https://kotlinlang.org. + +### Configuration + +- `build/templates` dir is used for Kotlinlang website templates. Currently, they should be put there manually. + +### Assembling + +To assemble API reference run: +```shell +$ ./gradlew :gradle:documentation:dokkaKotlinlangDocumentation -Pteamcity=true +``` + +Once build is finished - API reference is available in `build/documentation/kotlinlang` directory. diff --git a/libraries/tools/gradle/documentation/build.gradle.kts b/libraries/tools/gradle/documentation/build.gradle.kts index 66f1b11bc17f6..1433ec0e3f3a6 100644 --- a/libraries/tools/gradle/documentation/build.gradle.kts +++ b/libraries/tools/gradle/documentation/build.gradle.kts @@ -7,6 +7,7 @@ pluginsApiDocumentation { documentationOldVersions = layout.buildDirectory.dir("documentation/kotlinlangOld") 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") 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 564ba5cae5cd0..afe9d6ea2527f 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 @@ -17,5 +17,6 @@ abstract class PluginsApiDocumentationExtension @Inject constructor( 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 } \ 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 75f8d544e2d9d..1dc5dc926b918 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 @@ -17,18 +17,33 @@ dependencies { val downloadTask = tasks.register("downloadTemplates") { src(documentationExtension.templatesArchiveUrl) dest(layout.buildDirectory.file("templateDist.zip")) + onlyIf( + "Kotlinlang Dokka template is not working in the standalone mode: KT-73082" + ) { + false + } + onlyIfModified(true) overwrite(false) } val unzipTemplates = tasks.register("unzipTemplates") { dependsOn(downloadTask) + onlyIf( + "Kotlinlang Dokka template is not working in the standalone mode: KT-73082" + ) { + false + } + + val dirPrefix = documentationExtension.templatesArchivePrefixToRemove from( zipTree(downloadTask.map { it.dest }) .matching { include(documentationExtension.templatesArchiveSubDirectoryPattern.get()) } - ) + ).eachFile { + path = path.removePrefix(dirPrefix.get()) + } into(layout.buildDirectory.dir("template")) } @@ -54,12 +69,12 @@ tasks.register("dokkaKotlinlang dependsOn(unzipTemplates) pluginsMapConfiguration.put( "org.jetbrains.dokka.base.DokkaBase", - "{ \"templatesDir\": \"${unzipTemplates.map { it.destinationDir }.get()}\" }" + "{ \"templatesDir\": \"${unzipTemplates.map { it.destinationDir }.get().also { it.mkdirs() }}\" }" ) pluginsMapConfiguration.put( "org.jetbrains.dokka.versioning.VersioningPlugin", documentationExtension.documentationOldVersions.map { olderVersionsDir -> - "{ \"version\":\"$version\", \"olderVersionsDir\":\"${olderVersionsDir.asFile}\" }" + "{ \"version\":\"$version\", \"olderVersionsDir\":\"${olderVersionsDir.asFile.also { it.mkdirs() }}\" }" } )