Skip to content

Commit be31f19

Browse files
TapchicomaALikhachev
authored andcommitted
[Gradle] Fix documentation publishing to Kotlinlang
The Template was applied only to the final aggregate, but not to the partial tasks. ^KT-73128 Fixed
1 parent f959bf2 commit be31f19

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

libraries/tools/gradle/documentation/Readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This project assembles API reference for Kotlin Gradle plugins to publish it to
44

55
### Configuration
66

7-
- `build/templates` dir is used for Kotlinlang website templates. Currently, they should be put there manually.
7+
- `<root_dir>/build/api-reference/templates/` dir is used for Kotlinlang website templates. Currently, they should be put there manually.
88
- `build/documentation/kotlinlangOld` directory is used for previously generated documentation.
99
Inside the structure of subdirectories
1010
should follow [this specification](https://github.com/Kotlin/dokka/tree/1.9.20/dokka-subprojects/plugin-versioning#directory-structure).

libraries/tools/gradle/documentation/build.gradle.kts

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ pluginsApiDocumentation {
88
templatesArchiveUrl = "https://github.com/JetBrains/kotlin-web-site/archive/refs/heads/master.zip"
99
templatesArchiveSubDirectoryPattern = "kotlin-web-site-master/dokka-templates/**"
1010
templatesArchivePrefixToRemove = "kotlin-web-site-master/dokka-templates/"
11-
gradlePluginsProjects = setOf(
12-
project(":kotlin-gradle-plugin-api"),
13-
project(":compose-compiler-gradle-plugin")
14-
)
11+
addGradlePluginProject(project(":kotlin-gradle-plugin-api"))
12+
addGradlePluginProject(project(":compose-compiler-gradle-plugin"))
1513
}

repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/PluginsApiDocumentationExtension.kt

+7-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ import javax.inject.Inject
1212

1313
abstract class PluginsApiDocumentationExtension @Inject constructor(
1414
objectFactory: ObjectFactory,
15+
private val childProjectConfiguration: (Project) -> Unit
1516
) {
1617
abstract val documentationOutput: DirectoryProperty
1718
abstract val documentationOldVersions: DirectoryProperty
1819
abstract val templatesArchiveUrl: Property<String>
1920
val templatesArchiveSubDirectoryPattern: Property<String> = objectFactory.property(String::class.java).convention("")
2021
val templatesArchivePrefixToRemove: Property<String> = objectFactory.property(String::class.java).convention("")
21-
abstract val gradlePluginsProjects: SetProperty<Project>
22+
internal abstract val gradlePluginsProjects: SetProperty<Project>
23+
24+
fun addGradlePluginProject(project: Project) {
25+
gradlePluginsProjects.add(project)
26+
childProjectConfiguration(project)
27+
}
2228
}

repo/gradle-build-conventions/gradle-plugins-documentation/src/main/kotlin/gradle-plugins-documentation.gradle.kts

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
import de.undercouch.gradle.tasks.download.Download
22
import gradle.publishGradlePluginsJavadoc
33
import org.jetbrains.dokka.gradle.DokkaMultiModuleFileLayout
4+
import org.jetbrains.dokka.gradle.DokkaTaskPartial
45

56
plugins {
67
id("org.jetbrains.dokka")
78
base
89
}
910

10-
val documentationExtension = extensions.create<PluginsApiDocumentationExtension>("pluginsApiDocumentation")
11+
val templateConfig = Pair(
12+
"org.jetbrains.dokka.base.DokkaBase",
13+
"{ \"templatesDir\": \"${project.rootDir.resolve("build/api-reference/templates").also { it.mkdirs() }}\" }"
14+
)
15+
16+
val documentationExtension = extensions.create<PluginsApiDocumentationExtension>(
17+
"pluginsApiDocumentation",
18+
{ project: Project ->
19+
project.tasks.withType<DokkaTaskPartial>().configureEach {
20+
pluginsMapConfiguration.put(templateConfig.first, templateConfig.second)
21+
}
22+
}
23+
)
1124

1225
dependencies {
1326
dokkaPlugin(versionCatalogs.named("libs").findLibrary("dokka-versioningPlugin").get())
@@ -67,10 +80,7 @@ tasks.register<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("dokkaKotlinlang
6780
)
6881

6982
dependsOn(unzipTemplates)
70-
pluginsMapConfiguration.put(
71-
"org.jetbrains.dokka.base.DokkaBase",
72-
"{ \"templatesDir\": \"${unzipTemplates.map { it.destinationDir }.get().also { it.mkdirs() }}\" }"
73-
)
83+
pluginsMapConfiguration.put(templateConfig.first, templateConfig.second)
7484

7585
// Documentation: https://github.com/Kotlin/dokka/tree/1.9.20/dokka-subprojects/plugin-versioning
7686
pluginsMapConfiguration.put(

0 commit comments

Comments
 (0)