-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
57 lines (46 loc) · 1.71 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@file:Suppress("UnstableApiUsage")
plugins {
id("org.jetbrains.dokka") version "1.4.10.2"
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven("https://dl.bintray.com/kotlin/kotlinx")
}
}
tasks.dokkaHtmlMultiModule.configure {
outputDirectory.set(projectDir.resolve("docs").resolve(project.version.toString()))
}
tasks {
val docsDir = projectDir.resolve("docs")
val renameModulesToIndex by registering {
doLast {
logger.lifecycle("---=== Renaming -modules.html to index.html ===---")
docsDir.listFiles()
?.filter { it.isDirectory }
?.forEach { dir ->
dir.listFiles()
?.find { file -> file.name == "-modules.html" }
?.renameTo(File(dir, "index.html"))
}
}
}
val generateDocsIndexTask by registering {
doLast {
logger.lifecycle("---=== Generating index.html for docs ===---")
val docsSubDirs = docsDir.listFiles()
?.filter { it.isDirectory }
?.joinToString("\n") { dir -> "<li><a href=\"${dir.name}\">${dir.name}</a></li>" }
val html = """|<!doctype html><head><title>Choose a Version</title></head><body>
|<h1>Pick a Version</h1><ul>
|$docsSubDirs
|</ul></body></html>""".trimMargin()
docsDir.resolve("index.html").writeText(html)
}
}
dokkaHtmlMultiModule {
outputDirectory.set(docsDir.resolve(project.version.toString()))
finalizedBy(renameModulesToIndex, generateDocsIndexTask)
}
}