-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
152 lines (125 loc) · 4.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import org.jetbrains.dokka.gradle.DokkaTask
plugins {
idea
`maven-publish`
kotlin("jvm") version "1.3.40"
id("org.jetbrains.dokka") version "0.9.18"
}
description = "ISO 9362:2014 Business Identifier Codes"
group = "com.fleshgrinder.kotlin"
version = "0.1.0"
repositories { jcenter() }
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib") {
version { prefer("latest.release") }
}
val junitBom = platform("org.junit:junit-bom:5.4.2")
testImplementation(junitBom)
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly(junitBom)
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
tasks.apply {
wrapper { distributionType = Wrapper.DistributionType.ALL }
idea {
module {
isDownloadJavadoc = false
isDownloadSources = System.getenv("CI") != null
}
}
compileKotlin {
kotlinOptions {
allWarningsAsErrors = true
}
}
compileTestKotlin {
kotlinOptions {
allWarningsAsErrors = true
jvmTarget = "1.8"
}
}
test {
useJUnitPlatform()
testLogging { events("passed", "skipped", "failed") }
}
withType<DokkaTask>().configureEach {
dependsOn("clean${name.capitalize()}")
samples = listOf("$rootDir/src/test/kotlin")
}
dokka {
includes = listOf("PACKAGE.md", "README.md")
outputDirectory = "$buildDir/docs"
outputFormat = "html"
}
val docs by registering(Copy::class) {
val dokka = dokka.get()
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Copies the Dokka generated documentation into the `/docs` directory for GitHub publishing."
dependsOn("cleanDocs", dokka)
val hljs = """./style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.13.1/build/styles/atom-one-dark.min.css">
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.13.1/build/highlight.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.13.1/build/languages/kotlin.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>"""
from("${dokka.outputDirectory}/style.css")
from("${dokka.outputDirectory}/${dokka.moduleName}") {
exclude("index-outline.html", "package-list")
filter { it.replace("../style.css\">", hljs)}
}
into("$rootDir/docs")
}
// region ------------------------------------------------------------------ publishing
withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
remove(javadoc)
val javadoc by registering(DokkaTask::class) {
includes = listOf("PACKAGE.md")
outputDirectory = "$buildDir/javadoc"
outputFormat = "javadoc"
}
val javadocJar by registering(Jar::class) {
group = "build"
description = "Assembles a jar archive containing the source documentation."
archiveClassifier.set("javadoc")
from(javadoc)
}
val sourcesJar by registering(Jar::class) {
group = "build"
description = "Assembles a jar archive containing the source files."
archiveClassifier.set("sources")
from(sourceSets.main.get().allJava)
}
publishing {
repositories {
val user = cfgOrNull("com.bintray.user")
val key = cfgOrNull("com.bintray.key")
if (user == null && key == null) {
maven(uri("$buildDir/local-maven-repository"))
} else {
maven(uri("https://api.bintray.com/maven/$user/$group/$name/;publish=1")) {
name = "bintray"
credentials {
username = user
password = key
}
}
}
}
publications {
register("mavenJava", MavenPublication::class) {
from(project.components["java"])
artifact(sourcesJar.get())
artifact(javadocJar.get())
}
}
}
// endregion --------------------------------------------------------------- publishing
}
// region ---------------------------------------------------------------------- utils
fun env(name: String): String? = System.getenv(name.replace('.', '_').toUpperCase())
fun cfg(name: String) = env(name) ?: project.property(name) as String
fun cfgOrNull(name: String) = env(name) ?: project.findProperty(name) as String?
// endregion ------------------------------------------------------------------- utils