Skip to content

Commit

Permalink
[Gradle] Fix documentation publishing to Kotlinlang
Browse files Browse the repository at this point in the history
The Template was applied only to the final aggregate, but not to the
partial tasks.

^KT-73128 Fixed
  • Loading branch information
Tapchicoma authored and ALikhachev committed Nov 18, 2024
1 parent f959bf2 commit be31f19
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libraries/tools/gradle/documentation/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
- `<root_dir>/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).
Expand Down
6 changes: 2 additions & 4 deletions libraries/tools/gradle/documentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>
val templatesArchiveSubDirectoryPattern: Property<String> = objectFactory.property(String::class.java).convention("")
val templatesArchivePrefixToRemove: Property<String> = objectFactory.property(String::class.java).convention("")
abstract val gradlePluginsProjects: SetProperty<Project>
internal abstract val gradlePluginsProjects: SetProperty<Project>

fun addGradlePluginProject(project: Project) {
gradlePluginsProjects.add(project)
childProjectConfiguration(project)
}
}
Original file line number Diff line number Diff line change
@@ -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<PluginsApiDocumentationExtension>("pluginsApiDocumentation")
val templateConfig = Pair(
"org.jetbrains.dokka.base.DokkaBase",
"{ \"templatesDir\": \"${project.rootDir.resolve("build/api-reference/templates").also { it.mkdirs() }}\" }"
)

val documentationExtension = extensions.create<PluginsApiDocumentationExtension>(
"pluginsApiDocumentation",
{ project: Project ->
project.tasks.withType<DokkaTaskPartial>().configureEach {
pluginsMapConfiguration.put(templateConfig.first, templateConfig.second)
}
}
)

dependencies {
dokkaPlugin(versionCatalogs.named("libs").findLibrary("dokka-versioningPlugin").get())
Expand Down Expand Up @@ -67,10 +80,7 @@ tasks.register<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("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(
Expand Down

0 comments on commit be31f19

Please sign in to comment.