-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.gradle.kts
327 lines (275 loc) · 10.4 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
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseProject
import com.matthewprenger.cursegradle.CurseRelation
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import java.time.Year
@Suppress(
"DSL_SCOPE_VIOLATION",
"MISSING_DEPENDENCY_CLASS",
"UNRESOLVED_REFERENCE_WRONG_RECEIVER",
"FUNCTION_CALL_EXPECTED"
)
plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.quilt.loom)
alias(libs.plugins.detekt)
alias(libs.plugins.licenser)
alias(libs.plugins.git.hooks)
alias(libs.plugins.dokka)
alias(libs.plugins.binary.compatibility)
alias(libs.plugins.minotaur)
alias(libs.plugins.cursegradle)
`maven-publish`
}
buildscript {
dependencies {
classpath(libs.dokka.base)
}
}
group = "org.quiltmc"
val rootVersion = project.version
val flkVersion = rootProject.libs.versions.fabric.kotlin.get().substringBefore('+')
version = "${project.version}+kt.${project.libs.versions.kotlin.orNull}+flk.$flkVersion"
val projectVersion = project.version as String + if (System.getenv("SNAPSHOTS_URL") != null && System.getenv("MAVEN_URL") == null) "-SNAPSHOT" else ""
// 8 <= 1.17-alpha.21.18.a, 16 >= 1.17-alpha.21.19.a, 17 >= 1.18-beta.2, 21 >= 1.20.5-alpha.24.14.a
val javaVersion = 21 // The current version of Java used by Minecraft
repositories {
mavenCentral()
}
fun DependencyHandlerScope.includeApi(dependency: Any) {
api(dependency)
include(dependency)
}
dependencies {
includeApi(project(":core"))
includeApi(project(":library"))
}
allprojects {
apply(plugin=rootProject.libs.plugins.kotlin.get().pluginId)
apply(plugin=rootProject.libs.plugins.detekt.get().pluginId)
apply(plugin=rootProject.libs.plugins.licenser.get().pluginId)
apply(plugin=rootProject.libs.plugins.dokka.get().pluginId)
apply(plugin="maven-publish")
apply(plugin=rootProject.libs.plugins.quilt.loom.get().pluginId)
repositories {
mavenCentral()
}
detekt {
config.setFrom(files("${rootProject.projectDir}/codeformat/detekt.yml"))
}
license {
rule(file("${rootProject.projectDir}/codeformat/HEADER"))
}
kotlin {
// Enable explicit API mode, as this is a library
explicitApi()
jvmToolchain(javaVersion)
compilerOptions {
languageVersion = KotlinVersion.fromVersion(
rootProject.libs.plugins.kotlin.get().version.requiredVersion.substringBeforeLast(".")
)
}
}
tasks {
processResources {
inputs.property("version", rootVersion)
filesMatching("quilt.mod.json") {
expand(
"version" to rootVersion,
"flk_version" to rootProject.libs.versions.fabric.kotlin.get()
)
}
}
// Every dokka task
withType<AbstractDokkaTask> {
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
val rootPath = "${rootProject.projectDir.absolutePath}/codeformat/dokka"
customStyleSheets = file("$rootPath/styles").listFiles()!!.toList()
customAssets = file("$rootPath/assets").listFiles()!!.toList()
templatesDir = file("$rootPath/templates")
footerMessage = "© ${Year.now().value} The Quilt Project"
}
doLast {
// Script overriding does not work, so we have to do it manually
val scriptsOut = outputDirectory.asFile.get().resolve("scripts")
val scriptsIn = file("${rootProject.projectDir}/codeformat/dokka/scripts")
if (project != rootProject) return@doLast
scriptsIn.listFiles()!!.forEach {
it.copyTo(scriptsOut.resolve(it.name), overwrite = true)
}
}
}
// Every `dokkaType` and `dokkaTypePartial` task
withType<AbstractDokkaLeafTask> {
dokkaSourceSets.configureEach {
val quiltMaven = "https://maven.quiltmc.org/repository/release/org/quiltmc"
// QSL
val qslBaseLink = "$quiltMaven/qsl"
val qslVersion = rootProject.libs.versions.qsl.get()
val qslLink = "$qslBaseLink/$qslVersion/qsl-$qslVersion-fat-javadoc.jar"
externalDocumentationLink("$qslLink/", "$qslLink/element-list")
// Minecraft (mapped with Quilt mappings)
val mappingBaseLink = "$quiltMaven/quilt-mappings"
val mappingVersion = rootProject.libs.versions.quilt.mappings.get()
val mappingLink = "$mappingBaseLink/$mappingVersion/quilt-mappings-$mappingVersion-javadoc.jar"
externalDocumentationLink("$mappingLink/", "$mappingLink/element-list")
}
}
}
group = "org.quiltmc.quilt-kotlin-libraries"
version = projectVersion
dependencies {
minecraft(rootProject.libs.minecraft)
mappings(
variantOf(rootProject.libs.quilt.mappings) {
classifier("intermediary-v2")
}
)
modImplementation(rootProject.libs.quilt.loader)
}
tasks {
processResources {
inputs.property("version", rootProject.version)
filesMatching("quilt.mod.json") {
expand(Pair("version", rootProject.version))
}
}
remapJar {
dependsOn(remapSourcesJar)
}
val dokkaJavadocJar by creating(Jar::class.java) {
group = "documentation"
archiveClassifier.set("javadoc")
from(dokkaJavadoc)
}
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.toVersion(javaVersion)
targetCompatibility = JavaVersion.toVersion(javaVersion)
}
publishing {
publications {
create<MavenPublication>("Maven") {
// Copy data from the kotlin component, notably dependencies
from(components.getByName("kotlin"))
artifactId = project.name
version = projectVersion
// Publish Sources Jar
artifact(tasks.remapSourcesJar.get().archiveFile) {
builtBy(tasks.remapSourcesJar)
this.classifier = "sources"
}
// Publish Javadoc
artifact(tasks.getByName<Jar>("dokkaJavadocJar").archiveFile) {
builtBy(tasks.getByName("dokkaJavadocJar"))
this.classifier = "javadoc"
}
}
}
repositories {
mavenLocal()
if (System.getenv("MAVEN_URL") != null) {
maven {
setUrl(System.getenv("MAVEN_URL"))
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
name = "Maven"
}
} else if (System.getenv("SNAPSHOTS_URL") != null) {
maven {
setUrl(System.getenv("SNAPSHOTS_URL"))
credentials {
username = System.getenv("SNAPSHOTS_USERNAME")
password = System.getenv("SNAPSHOTS_PASSWORD")
}
name = "Maven"
}
}
}
}
}
subprojects {
tasks {
remapJar {
archiveBaseName.set("quilt-kotlin-libraries-${project.name}")
dependsOn(remapSourcesJar)
}
remapSourcesJar {
archiveBaseName.set("quilt-kotlin-libraries-${project.name}")
}
named<Jar>("dokkaJavadocJar") {
archiveBaseName.set("quilt-kotlin-libraries-${project.name}")
}
}
}
tasks {
create("dokkaHtmlJar", Jar::class.java) {
group = "documentation"
archiveBaseName.set("quilt-kotlin-libraries")
archiveClassifier.set("dokka")
from(dokkaHtmlMultiModule.get().outputDirectory)
duplicatesStrategy = DuplicatesStrategy.FAIL
}
}
publishing {
publications {
getByName<MavenPublication>("Maven") {
val dokka = rootProject.tasks.getByName<Jar>("dokkaHtmlJar")
artifact(dokka.archiveFile) {
builtBy(dokka)
classifier = "dokka"
}
}
}
}
gitHooks {
// Before committing, check that licenses are all ready and the detekt checks have passed.
setHooks(mapOf("pre-commit" to "checkLicenses apiCheck detekt"))
}
apiValidation {
ignoredProjects.addAll(listOf("quilt-kotlin-libraries", "core"))
}
curseforge {
System.getenv("CURSEFORGE_TOKEN")?.let { apiKey = it }
project(closureOf<CurseProject> {
id = "720410"
releaseType = "release"
addGameVersion(libs.versions.minecraft.get())
addGameVersion("Quilt")
changelog = System.getenv("CHANGELOG") ?: "No changelog provided."
changelogType = "markdown"
mainArtifact(tasks.remapJar.get(), closureOf<CurseArtifact> {
displayName = "QKL $rootVersion + FLK $flkVersion + Kotlin ${project.libs.versions.kotlin.orNull}"
})
addArtifact(project(":core").tasks.remapJar.get())
relations(closureOf<CurseRelation> {
requiredDependency("qsl")
embeddedLibrary("fabric-language-kotlin")
})
})
curseGradleOptions.forgeGradleIntegration = false
}
tasks.curseforge.get().dependsOn(tasks.remapJar)
tasks.curseforge.get().dependsOn(project(":core").tasks.remapJar)
modrinth {
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("qkl")
versionName.set("QKL $rootVersion + FLK $flkVersion + Kotlin ${project.libs.versions.kotlin.orNull}")
versionType.set("release")
changelog.set(System.getenv("CHANGELOG") ?: "No changelog provided.")
file.set(tasks.remapJar.get().archiveFile)
additionalFiles.add(project(":core").tasks.remapJar.get().archiveFile)
dependencies {
required.project("qsl")
embedded.project("fabric-language-kotlin")
}
}
tasks.modrinth.get().dependsOn(tasks.remapJar)
tasks.modrinth.get().dependsOn(project(":core").tasks.remapJar)