forked from ajalt/clikt
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
69 lines (58 loc) · 2.28 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
58
59
60
61
62
63
64
65
66
67
68
69
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import java.io.ByteArrayOutputStream
plugins {
kotlin("multiplatform").version(libs.versions.kotlin).apply(false)
alias(libs.plugins.dokka).apply(false)
alias(libs.plugins.publish).apply(false)
}
fun getPublishVersion(): String {
val versionName = project.property("VERSION_NAME") as String
// Call gradle with -PinferVersion to set the dynamic version name.
// Otherwise, we skip it to save time.
if (!project.hasProperty("inferVersion")) return versionName
val stdout = ByteArrayOutputStream()
project.exec {
commandLine = listOf("git", "tag", "--points-at", "HEAD")
standardOutput = stdout
}
val tag = String(stdout.toByteArray()).trim()
if (tag.isNotEmpty()) return tag
val buildNumber = System.getenv("GITHUB_RUN_NUMBER") ?: "0"
return "$versionName.$buildNumber-SNAPSHOT"
}
subprojects {
project.setProperty("VERSION_NAME", getPublishVersion())
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
}
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}
pluginManager.withPlugin("com.vanniktech.maven.publish") {
apply(plugin = "org.jetbrains.dokka")
tasks.named<DokkaTask>("dokkaHtml") {
outputDirectory.set(rootProject.rootDir.resolve("docs/api"))
val rootPath = rootProject.rootDir.toPath()
val logoCss = rootPath.resolve("docs/css/logo-styles.css").toString().replace('\\', '/')
val paletteSvg = rootPath.resolve("docs/img/wordmark_small_dark.svg").toString()
.replace('\\', '/')
pluginsMapConfiguration.set(
mapOf(
"org.jetbrains.dokka.base.DokkaBase" to """{
"customStyleSheets": ["$logoCss"],
"customAssets": ["$paletteSvg"],
"footerMessage": "Copyright © 2021 AJ Alt"
}"""
)
)
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
skipDeprecated.set(true)
}
}
}
}