-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.gradle.kts
387 lines (347 loc) · 13.6 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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
/*
* Copyright (c) 2024 Fzzyhmstrs
*
* This file is part of Fzzy Config, a mod made for minecraft; as such it falls under the license of Fzzy Config.
*
* Fzzy Config is free software provided under the terms of the Timefall Development License - Modified (TDL-M).
* You should have received a copy of the TDL-M with this software.
* If you did not, see <https://github.com/fzzyhmstrs/Timefall-Development-Licence-Modified>.
* */
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseProject
import com.matthewprenger.cursegradle.CurseRelation
import com.matthewprenger.cursegradle.Options
import net.fabricmc.loom.task.RemapJarTask
import org.gradle.jvm.tasks.Jar
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.dokka.versioning.VersioningConfiguration
import org.jetbrains.dokka.versioning.VersioningPlugin
import org.jetbrains.kotlin.cli.common.toBooleanLenient
import java.net.URI
plugins {
id("fabric-loom")
val kotlinVersion: String by System.getProperties()
kotlin("jvm").version(kotlinVersion)
kotlin("plugin.serialization") version "1.9.22"
id("com.modrinth.minotaur") version "2.+"
id("org.jetbrains.dokka") version "1.9.20"
id("com.matthewprenger.cursegradle") version "1.4.0"
`maven-publish`
}
buildscript {
dependencies {
classpath("org.jetbrains.dokka:dokka-base:1.9.20")
classpath("org.jetbrains.dokka:versioning-plugin:1.9.20")
}
}
base {
val archivesBaseName: String by project
archivesName.set(archivesBaseName)
}
val log: File = file("changelog.md")
val minecraftVersion: String by project
val modVersion: String by project
version = "$modVersion+$minecraftVersion"
val mavenGroup: String by project
group = mavenGroup
println("## Changelog for FzzyConfig $version \n\n" + log.readText())
repositories {
mavenCentral()
mavenLocal()
maven {
url = URI("https://maven.terraformersmc.com/releases/")
content {
includeGroup ("com.terraformersmc")
}
}
}
sourceSets {
main {
kotlin {
val includeExamples: String by project
if (includeExamples.toBooleanLenient() != true) {
exclude("me/fzzyhmstrs/fzzy_config/examples/**")
}
}
}
create("testmod"){
compileClasspath += sourceSets.main.get().compileClasspath
runtimeClasspath += sourceSets.main.get().runtimeClasspath
}
}
val testmodImplementation by configurations.getting {
extendsFrom(configurations.implementation.get())
}
idea {
module {
testSources.from(sourceSets["testmod"].java.srcDirs)
testSources.from(sourceSets["testmod"].kotlin.srcDirs)
}
}
dependencies {
minecraft("com.mojang:minecraft:$minecraftVersion")
val yarnMappings: String by project
mappings("net.fabricmc:yarn:$yarnMappings:v2")
val loaderVersion: String by project
modImplementation("net.fabricmc:fabric-loader:$loaderVersion")
val fabricVersion: String by project
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricVersion")
val fabricKotlinVersion: String by project
modImplementation("net.fabricmc:fabric-language-kotlin:$fabricKotlinVersion")
val tomlktVersion: String by project
implementation("net.peanuuutz.tomlkt:tomlkt:$tomlktVersion")
include("net.peanuuutz.tomlkt:tomlkt-jvm:$tomlktVersion")
val janksonVersion: String by project
implementation("blue.endless:jankson:$janksonVersion")
include("blue.endless:jankson:$janksonVersion")
val fabricPermsVersion: String by project
modImplementation("me.lucko:fabric-permissions-api:$fabricPermsVersion")
include("me.lucko:fabric-permissions-api:$fabricPermsVersion")
val modmenuVersion: String by project
modCompileOnly("com.terraformersmc:modmenu:$modmenuVersion") {
isTransitive = false
}
modLocalRuntime("com.terraformersmc:modmenu:$modmenuVersion") {
isTransitive = false
}
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
testmodImplementation(sourceSets.main.get().output)
dokkaPlugin("me.fzzyhmstrs:internal-skip-plugin:1.0-SNAPSHOT")
dokkaPlugin("org.jetbrains.dokka:versioning-plugin:1.9.20")
}
loom {
runs {
create("testmodClient"){
client()
name = "Testmod Client"
source(sourceSets["testmod"])
}
}
}
tasks {
val javaVersion = JavaVersion.VERSION_21
withType<JavaCompile> {
options.encoding = "UTF-8"
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
options.release.set(javaVersion.toString().toInt())
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = javaVersion.toString()
freeCompilerArgs = listOf("-Xjvm-default=all")
}
//java.sourceCompatibility = javaVersion
//targetCompatibility = javaVersion.toString()
}
jar {
exclude("me/fzzyhmstrs/fzzy_config/examples/**")
from("LICENSE") { rename { "${base.archivesName.get()}_${it}" } }
}
jar {
from( "credits.txt") { rename { "${base.archivesName.get()}_${it}" } }
}
processResources {
val loaderVersion: String by project
val fabricKotlinVersion: String by project
inputs.property("version", project.version)
inputs.property("id", base.archivesName.get())
inputs.property("loaderVersion", loaderVersion)
inputs.property("fabricKotlinVersion", fabricKotlinVersion)
filesMatching("fabric.mod.json") {
expand(mutableMapOf(
"version" to project.version,
"id" to base.archivesName.get(),
"loaderVersion" to loaderVersion,
"fabricKotlinVersion" to fabricKotlinVersion
)) }
}
java {
toolchain { languageVersion.set(JavaLanguageVersion.of(javaVersion.toString())) }
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
withSourcesJar()
}
modrinth.get().group = "upload"
modrinthSyncBody.get().group = "upload"
}
val testmodJar = tasks.register("testmodJar", Jar::class) {
from(sourceSets["testmod"].output)
destinationDirectory = File(project.layout.buildDirectory.get().asFile, "testmod")
archiveClassifier = "testmod"
}
val remapTestmodJar = tasks.register("remapTestmodJar", RemapJarTask::class){
dependsOn(testmodJar.get())
input.set(testmodJar.get().archiveFile)
archiveClassifier = "testmod"
addNestedDependencies = false
//destinationDirectory = File(project.layout.buildDirectory.get().asFile, "testmod")
}
tasks.build{
dependsOn(remapTestmodJar.get())
}
tasks.withType<DokkaTask>().configureEach {
inputs.dir(file("dokka"))
val docVersionsDir = projectDir.resolve("build/dokka/version")
// The version for which you are currently generating docs
val currentVersion = project.version.toString()
// Set the output to a folder with all other versions
// as you'll need the current version for future builds
val currentDocsDir = docVersionsDir.resolve(currentVersion)
outputDirectory.set(currentDocsDir)
dokkaSourceSets.configureEach {
perPackageOption {
matchingRegex.set("me.fzzyhmstrs.fzzy_config.examples|me.fzzyhmstrs.fzzy_config.impl|me.fzzyhmstrs.fzzy_config.test|me.fzzyhmstrs.fzzy_config.updates|me.fzzyhmstrs.fzzy_config")
suppress.set(true)
}
includes.from(project.files(), "dokka/module.md")
}
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
moduleName = "Fzzy Config"
customAssets = listOf(
file("dokka/assets/fc_banner.png"),
file("dokka/assets/discord_banner.png"),
file("dokka/assets/discord_small_banner.png"),
file("dokka/assets/wiki_banner.png"),
file("dokka/assets/wiki_small_banner.png"),
file("dokka/assets/docs_banner.png"),
file("dokka/assets/docs_small_banner.png"),
file("dokka/assets/cf_banner.png"),
file("dokka/assets/modrinth_banner.png"),
file("src/main/resources/icon.png"))
customStyleSheets = listOf(file("dokka/style.css"),file("dokka/logo-styles.css"))
templatesDir = file("dokka")
footerMessage = "(c) 2024 fzzyhmstrs"
}
pluginConfiguration<VersioningPlugin, VersioningConfiguration> {
olderVersionsDir = docVersionsDir
version = currentVersion
}
doLast {
// This folder contains the latest documentation with all
// previous versions included, so it's ready to be published.
// Make sure it's copied and not moved - you'll still need this
// version for future builds
currentDocsDir.copyRecursively(file("docs"), overwrite = true)
// Only once current documentation has been safely moved,
// remove previous versions bundled in it. They will not
// be needed in future builds, it's just overhead.
currentDocsDir.resolve("older").deleteRecursively()
}
}
if (System.getenv("MODRINTH_TOKEN") != null) {
modrinth {
val releaseType: String by project
val mcVersions: String by project
val uploadDebugMode: String by project
token.set(System.getenv("MODRINTH_TOKEN"))
projectId.set("fzzy-config")
versionNumber.set("${project.version}")
versionName.set("${base.archivesName.get()}-${project.version}")
versionType.set(releaseType)
uploadFile.set(tasks.remapJar.get())
additionalFiles.add(tasks.remapSourcesJar.get().archiveFile)
gameVersions.addAll(mcVersions.split(","))
loaders.addAll("fabric", "quilt")
detectLoaders.set(false)
changelog.set(log.readText())
dependencies {
required.project("fabric-api")
required.project("fabric-language-kotlin")
}
debugMode.set(uploadDebugMode.toBooleanLenient() ?: true)
}
}
if (System.getenv("CURSEFORGE_TOKEN") != null) {
curseforge {
val releaseType: String by project
val mcVersions: String by project
val mcCurseVersions: String by project
val uploadDebugMode: String by project
apiKey = System.getenv("CURSEFORGE_TOKEN")
project(closureOf<CurseProject> {
id = "1005914"
changelog = log
changelogType = "markdown"
this.releaseType = releaseType
val v = if (mcCurseVersions.isEmpty()) mcVersions else mcCurseVersions
for (ver in v.split(",")) {
addGameVersion(ver)
}
addGameVersion("Fabric")
addGameVersion("Quilt")
mainArtifact(tasks.remapJar.get().archiveFile.get(), closureOf<CurseArtifact> {
displayName = "${base.archivesName.get()}-${project.version}"
relations(closureOf<CurseRelation>{
this.requiredDependency("fabric-api")
this.requiredDependency("fabric-language-kotlin")
})
})
addArtifact(tasks.remapSourcesJar.get().archiveFile, closureOf<CurseArtifact> {
changelogType = "markdown"
changelog = "Source files for ${base.archivesName.get()}-${project.version}"
})
relations(closureOf<CurseRelation>{
this.requiredDependency("fabric-api")
this.requiredDependency("fabric-language-kotlin")
})
})
options(closureOf<Options> {
javaIntegration = false
forgeGradleIntegration = false
javaVersionAutoDetect = false
debug = uploadDebugMode.toBooleanLenient() ?: true
})
}
}
tasks.register("uploadAll") {
group = "upload"
dependsOn(tasks.modrinth.get())
dependsOn(tasks.curseforge.get())
dependsOn(tasks.publish.get())
}
publishing {
publications {
create<MavenPublication>("fzzyConfig") {
from(components["java"])
pom {
name.set("Fzzy Config")
description.set("Configuration engine with automatic GUI generation, client-server syncing, powerful validation and error handling, and much more.")
inceptionYear.set("2024")
licenses {
license {
name.set("TDL-M")
url.set("https://github.com/fzzyhmstrs/Timefall-Development-Licence-Modified")
distribution.set("repo")
comments.set(" Fzzy Config is free software provided under the terms of the Timefall Development License - Modified (TDL-M). See license url for full license details.")
}
}
scm {
url.set("https://github.com/fzzyhmstrs/fconfig")
}
issueManagement {
system.set("Github")
url.set("https://github.com/fzzyhmstrs/fconfig/issues")
}
developers {
developer {
name.set("Fzzyhmstrs")
url.set("https://github.com/fzzyhmstrs")
}
}
}
}
}
repositories {
maven {
name = "FzzyMaven"
url = uri("https://maven.fzzyhmstrs.me")
credentials {
username = System.getProperty("fzzyMavenUsername")
password = System.getProperty("fzzyMavenPassword")
}
}
}
}