Skip to content

Commit

Permalink
[Gradle] Fix templates extraction
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tapchicoma authored and qodana-bot committed Nov 14, 2024
1 parent 858b914 commit a7dabb6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
16 changes: 16 additions & 0 deletions libraries/tools/gradle/documentation/Readme.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions libraries/tools/gradle/documentation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ abstract class PluginsApiDocumentationExtension @Inject constructor(
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>
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,33 @@ dependencies {
val downloadTask = tasks.register<Download>("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<Copy>("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"))
}

Expand All @@ -54,12 +69,12 @@ tasks.register<org.jetbrains.dokka.gradle.DokkaMultiModuleTask>("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() }}\" }"
}
)

Expand Down

0 comments on commit a7dabb6

Please sign in to comment.