-
-
Notifications
You must be signed in to change notification settings - Fork 279
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
231 lines (195 loc) · 5.88 KB
/
build.gradle.kts
File metadata and controls
231 lines (195 loc) · 5.88 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.time.Year
plugins {
kotlin("jvm") version "2.3.10"
id("org.jetbrains.dokka") version "2.0.0"
id("org.jlleitschuh.gradle.ktlint") version "14.0.1"
id("com.github.ben-manes.versions") version "0.53.0"
id("se.patrikerdes.use-latest-versions") version "0.2.19"
application
}
group = "com.quarkdown"
version = file("version.txt").readText().trim()
allprojects {
repositories {
mavenCentral()
}
}
subprojects {
apply(plugin = "org.jetbrains.dokka")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "com.github.ben-manes.versions")
apply(plugin = "se.patrikerdes.use-latest-versions")
}
// Fat JAR / Distribution dependencies
gradle.projectsEvaluated {
dependencies {
subprojects.forEach {
when {
it.extra.has("noRuntime") && it.extra["noRuntime"] == true -> {
compileOnly(it)
}
else -> {
implementation(it)
}
}
}
}
}
application {
mainClass.set("com.quarkdown.cli.QuarkdownCliKt")
}
ktlint {
version.set("1.7.1")
}
// Dokka
dokka {
dokkaPublications.html {
outputDirectory.set(
layout.buildDirectory
.file("docs")
.get()
.asFile,
)
}
}
/**
* Whether [project] uses the Quarkdoc plugin, which means its documentation must be included in the distribution zip.
*/
fun usesQuarkdoc(project: Project): Boolean {
val quarkdoc = project(":quarkdown-quarkdoc")
return project.configurations
.asSequence()
.flatMap { it.dependencies }
.filterIsInstance<ProjectDependency>()
.any { it.dependencyProject == quarkdoc }
}
val quarkdocGenerate =
tasks.register("quarkdocGenerate") {
group = "documentation"
description = "Generates the Quarkdoc documentation for modules that include the Quarkdoc plugin."
dependencies {
subprojects.filter(::usesQuarkdoc).forEach {
dokka(it)
}
}
dependsOn(tasks.dokkaGenerate)
}
tasks.register("quarkdocGenerateAll") {
group = "documentation"
description = "Generates the Quarkdoc documentation for all modules."
dependencies {
subprojects.forEach {
dokka(it)
}
}
dependsOn(tasks.dokkaGenerate)
}
allprojects {
fun asset(path: String): File = project(":quarkdown-quarkdoc").projectDir.resolve("src/main/resources/$path")
dokka {
pluginsConfiguration.html {
val year = Year.now().value
footerMessage.set("© $year Quarkdown")
customAssets.from(*asset("assets/images").listFiles()!!)
customStyleSheets.from(asset("styles/stylesheet.css"))
}
}
}
// Tasks
/**
* Populates a [CopySpec] with the Quarkdown install library layout, with subdirectories such as `qd/` and `html/`.
* Used by both [distributions]`.main` and [assembleDevLib].
*
* This layout is navigable at runtime via the `install-layout-navigator` module.
*/
val installLibLayout: CopySpec.() -> Unit = {
// .qd library files.
into("qd") {
from(project(":quarkdown-libs").file("src/main/resources")) {
include("*.qd")
}
}
// HTML rendering resources (third-party libraries, themes, scripts) for offline rendering.
into("html") {
from(project(":quarkdown-html").layout.buildDirectory.dir("install"))
}
}
distributions.main {
contents {
into("lib", installLibLayout)
// Include the generated Dokka documentation, generated by quarkdocGenerate,
// in the 'docs' directory.
val dokkaOutputDir = layout.buildDirectory.file("docs")
from(dokkaOutputDir) {
into("docs")
}
}
}
// Assembles a dev-time install `lib/` layout at `<rootProject>/build/dev-lib`, mirroring
// the distribution layout so that `gradle run` and IntelliJ runs can resolve the install
// directory at runtime.
val assembleDevLib by tasks.registering(Sync::class) {
dependsOn(":quarkdown-html:bundleThirdParty")
into(layout.buildDirectory.dir("dev-lib"))
installLibLayout()
}
tasks.installDist {
dependsOn(quarkdocGenerate)
}
tasks.distZip {
dependsOn(quarkdocGenerate)
archiveVersion.set("")
}
tasks.distTar {
dependsOn(quarkdocGenerate)
archiveVersion.set("")
}
tasks.test {
useJUnitPlatform()
dependsOn(tasks.ktlintCheck)
}
tasks.named<CreateStartScripts>("startScripts") {
classpath = files("lib/*") // Fixes the 'Input line is too long' error on Windows.
// Prepends subscripts to the generated start scripts.
doLast {
val dir = file("scripts")
val scripts = sequenceOf("bootstrap")
scripts.forEach { scriptName ->
val unixPrefix = dir.resolve("$scriptName.sh").readText() + "\n"
val windowsPrefix = dir.resolve("$scriptName.bat").readText() + "\n"
unixScript.writeText("#!/bin/sh\n\n" + unixPrefix + unixScript.readText())
windowsScript.writeText("@echo off\n\n" + windowsPrefix + windowsScript.readText())
}
}
}
tasks.wrapper {
gradleVersion = "8.3"
distributionType = Wrapper.DistributionType.ALL
}
tasks.withType<KotlinCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
}
}
tasks.register("printVersion") {
doLast {
println(project.version)
}
}
// Dependency updates
allprojects {
tasks.dependencyUpdates {
rejectVersionIf {
Regex("[.-](alpha|beta|rc|cr|m|preview|b|ea)", RegexOption.IGNORE_CASE) in candidate.version
}
}
tasks.useLatestVersions {
updateBlacklist =
listOf(
"org.jetbrains.kotlin",
"org.jetbrains.dokka",
)
}
}