Skip to content

Commit a7dabb6

Browse files
TapchicomaSpace Team
authored and
Space Team
committed
[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
1 parent 858b914 commit a7dabb6

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Kotlinlang Gradle API reference
2+
3+
This project assembles API reference for Kotlin Gradle plugins to publish it to https://kotlinlang.org.
4+
5+
### Configuration
6+
7+
- `build/templates` dir is used for Kotlinlang website templates. Currently, they should be put there manually.
8+
9+
### Assembling
10+
11+
To assemble API reference run:
12+
```shell
13+
$ ./gradlew :gradle:documentation:dokkaKotlinlangDocumentation -Pteamcity=true
14+
```
15+
16+
Once build is finished - API reference is available in `build/documentation/kotlinlang` directory.

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

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ pluginsApiDocumentation {
77
documentationOldVersions = layout.buildDirectory.dir("documentation/kotlinlangOld")
88
templatesArchiveUrl = "https://github.com/JetBrains/kotlin-web-site/archive/refs/heads/master.zip"
99
templatesArchiveSubDirectoryPattern = "kotlin-web-site-master/dokka-templates/**"
10+
templatesArchivePrefixToRemove = "kotlin-web-site-master/dokka-templates/"
1011
gradlePluginsProjects = setOf(
1112
project(":kotlin-gradle-plugin-api"),
1213
project(":compose-compiler-gradle-plugin")

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

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ abstract class PluginsApiDocumentationExtension @Inject constructor(
1717
abstract val documentationOldVersions: DirectoryProperty
1818
abstract val templatesArchiveUrl: Property<String>
1919
val templatesArchiveSubDirectoryPattern: Property<String> = objectFactory.property(String::class.java).convention("")
20+
val templatesArchivePrefixToRemove: Property<String> = objectFactory.property(String::class.java).convention("")
2021
abstract val gradlePluginsProjects: SetProperty<Project>
2122
}

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

+18-3
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,33 @@ dependencies {
1717
val downloadTask = tasks.register<Download>("downloadTemplates") {
1818
src(documentationExtension.templatesArchiveUrl)
1919
dest(layout.buildDirectory.file("templateDist.zip"))
20+
onlyIf(
21+
"Kotlinlang Dokka template is not working in the standalone mode: KT-73082"
22+
) {
23+
false
24+
}
25+
2026
onlyIfModified(true)
2127
overwrite(false)
2228
}
2329

2430
val unzipTemplates = tasks.register<Copy>("unzipTemplates") {
2531
dependsOn(downloadTask)
32+
onlyIf(
33+
"Kotlinlang Dokka template is not working in the standalone mode: KT-73082"
34+
) {
35+
false
36+
}
37+
38+
val dirPrefix = documentationExtension.templatesArchivePrefixToRemove
2639
from(
2740
zipTree(downloadTask.map { it.dest })
2841
.matching {
2942
include(documentationExtension.templatesArchiveSubDirectoryPattern.get())
3043
}
31-
)
44+
).eachFile {
45+
path = path.removePrefix(dirPrefix.get())
46+
}
3247
into(layout.buildDirectory.dir("template"))
3348
}
3449

@@ -54,12 +69,12 @@ tasks.register<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("dokkaKotlinlang
5469
dependsOn(unzipTemplates)
5570
pluginsMapConfiguration.put(
5671
"org.jetbrains.dokka.base.DokkaBase",
57-
"{ \"templatesDir\": \"${unzipTemplates.map { it.destinationDir }.get()}\" }"
72+
"{ \"templatesDir\": \"${unzipTemplates.map { it.destinationDir }.get().also { it.mkdirs() }}\" }"
5873
)
5974
pluginsMapConfiguration.put(
6075
"org.jetbrains.dokka.versioning.VersioningPlugin",
6176
documentationExtension.documentationOldVersions.map { olderVersionsDir ->
62-
"{ \"version\":\"$version\", \"olderVersionsDir\":\"${olderVersionsDir.asFile}\" }"
77+
"{ \"version\":\"$version\", \"olderVersionsDir\":\"${olderVersionsDir.asFile.also { it.mkdirs() }}\" }"
6378
}
6479
)
6580

0 commit comments

Comments
 (0)