-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle_old.kts
428 lines (366 loc) · 13.1 KB
/
build.gradle_old.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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
@file:Suppress("INACCESSIBLE_TYPE", "UnstableApiUsage")
import io.github.opencubicchunks.gradle.GeneratePackageInfo
import org.gradle.internal.os.OperatingSystem
import java.util.*
buildscript {
dependencies {
classpath("com.google.code.gson:gson:2.8.5")
}
}
plugins {
id("fabric-loom")
id("maven-publish")
id("checkstyle")
id("io.github.juuxel.loom-quiltflower").version("1.7.2")
id("io.github.opencubicchunks.javaheaders").version("1.2.7")
id("io.github.opencubicchunks.gradle.mcGitVersion")
id("io.github.opencubicchunks.gradle.mixingen")
id("io.github.opencubicchunks.gradle.dasm")
}
val minecraftVersion: String by project
val loaderVersion: String by project
val fabricVersion: String by project
val lwjglVersion: String by project
val lwjglNatives: String by project
val modId: String by project
val debugArtifactTransforms: String by project
javaHeaders {
setAcceptedJars(".*CubicChunksCore.*")
setConfig(file("javaHeaders.json"))
setDebug(debugArtifactTransforms.toBoolean())
}
mcGitVersion {
isSnapshot = true
mcVersion = minecraftVersion
setCommitVersion("570c0cbf0cdc15b8348a862a519d3399a943af9", "0.0")
}
val generatePackageInfo: Task by tasks.creating
generatePackageInfo.apply {
group = "filegen"
doFirst {
GeneratePackageInfo.generateFiles(project.sourceSets["main"])
GeneratePackageInfo.generateFiles(project.sourceSets["test"])
}
}
val genAll: Task by tasks.creating {
group = "filegen"
dependsOn(generatePackageInfo, "generateMixinConfigs")
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
mixinGen {
filePattern = "cubicchunks.mixins.%s.json"
defaultRefmap = "CubicChunks-refmap.json"
defaultPackagePrefix = "io.github.opencubicchunks.cubicchunks.mixin"
defaultCompatibilityLevel = "JAVA_17"
defaultMinVersion = "0.8"
config("core") {
required = true
conformVisibility = true
injectorsDefaultRequire = 1
configurationPlugin = "io.github.opencubicchunks.cubicchunks.mixin.AnnotationConfigPlugin"
}
config("levelgen") {
required = true
conformVisibility = true
injectorsDefaultRequire = 1
}
config("access") {
required = true
conformVisibility = true
}
config("asm") {
required = true
configurationPlugin = "io.github.opencubicchunks.cubicchunks.mixin.ASMConfigPlugin"
}
config("asmfixes") {
required = true
injectorsDefaultRequire = 1
}
config("optifine") {
required = true
configurationPlugin = "io.github.opencubicchunks.cubicchunks.mixin.OptiFineMixinConfig"
injectorsDefaultRequire = 1
}
config("debug") {
required = false
conformVisibility = true
injectorsDefaultRequire = 0
configurationPlugin = "io.github.opencubicchunks.cubicchunks.mixin.DebugMixinConfig"
}
config("test") {
required = true
conformVisibility = true
injectorsDefaultRequire = 1
configurationPlugin = "io.github.opencubicchunks.cubicchunks.mixin.TestMixinConfig"
}
}
group = "io.github.opencubicchunks" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
base {
archivesName.set("CubicChunks")
}
configurations.all {
resolutionStrategy {
force("net.fabricmc:fabric-loader:${loaderVersion}")
}
}
val debugCompile: Configuration by configurations.creating
val debugRuntime: Configuration by configurations.creating {
extendsFrom(debugCompile)
}
val extraTests: Configuration by configurations.creating
val shade: Configuration by configurations.creating
sourceSets {
create("debug") {
compileClasspath += debugCompile
compileClasspath += configurations.compileClasspath.get()
compileClasspath += sourceSets.main.get().output
runtimeClasspath += debugRuntime
runtimeClasspath += configurations.runtimeClasspath.get()
runtimeClasspath += sourceSets.main.get().output
}
}
repositories {
mavenCentral()
maven {
setUrl("https://oss.sonatype.org/content/repositories/snapshots/")
}
maven {
setUrl("https://repo.spongepowered.org/maven/")
}
maven {
name = "ParchmentMC"
setUrl("https://maven.parchmentmc.net/")
}
maven {
name = "JitPack"
setUrl("https://jitpack.io")
}
maven {
name = "Gegy"
setUrl("https://maven.gegy.dev")
}
}
loom {
createRemapConfigurations(sourceSets.test.get())
accessWidenerPath.set(file("src/main/resources/cubicchunks.accesswidener"))
// intermediaryUrl = { "http://localhost:9000/intermediary-20w49a-v2.jar" }
val dependency = project.configurations.detachedConfiguration(project.dependencies.create("net.fabricmc:sponge-mixin:0.11.2+mixin.0.8.5"))
dependency.isTransitive = false
val mixinFile = dependency.resolve().iterator().next().toString()
val args = listOf(
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+AllowEnhancedClassRedefinition",
"-XX:-OmitStackTraceInFastThrow",
"-XX:+UseG1GC",
"-XX:G1NewSizePercent=20",
"-XX:G1ReservePercent=20",
"-XX:MaxGCPauseMillis=50",
"-XX:G1HeapRegionSize=32M",
"-javaagent:" + mixinFile,
"-Dmixin.debug.verbose=true",
"-Dmixin.debug.export=true",
"-Dmixin.checks.interfaces=true",
"-Dcubicchunks.debug=false",
"-Dcubicchunks.debug.loadorder=false",
"-Dcubicchunks.debug.window=false",
"-Dcubicchunks.debug.statusrenderer=false",
"-Dcubicchunks.debug.heightmaprenderer=false",
"-Dcubicchunks.debug.heightmaprenderer.server=false",
"-Dcubicchunks.debug.heightmaprenderer.render_lightmap=false",
"-Dcubicchunks.debug.heightmaprenderer.radius=2",
"-Dcubicchunks.debug.heightmapverification=false",
"-Dcubicchunks.debug.heightmapverification.frequency=1",
"-Dcubicchunks.debug.biomes=false",
"-ea"
)
runConfigs {
get("client").apply {
client()
vmArgs("-Xmx2G")
}
get("server").apply {
server()
vmArgs("-Xmx2G")
}
create("client4g").apply {
client()
vmArgs("-Xmx4G")
}
create("server4g").apply {
server()
vmArgs("-Xmx4G")
}
}
runConfigs.configureEach {
isIdeConfigGenerated = true
vmArgs(args)
}
}
// for vulkan
project.ext["lwjglVersion"] = "3.2.2"
when (OperatingSystem.current()) {
OperatingSystem.LINUX -> {
@Suppress("UnstableApiUsage") val osArch = System.getProperty("os.arch")
project.ext["lwjglNatives"] = if (osArch.startsWith("arm") || osArch.startsWith("aarch64"))
"natives-linux-${if (osArch.contains("64") || osArch.startsWith("armv8")) "arm64" else "arm32"}"
else "natives-linux"
}
OperatingSystem.WINDOWS -> {
project.ext["lwjglNatives"] = if (System.getProperty("os.arch").contains("64")) "natives-windows" else "natives-windows-x86"
}
OperatingSystem.MAC_OS -> {
project.ext["lwjglNatives"] = "natives-macos"
project.ext["lwjglVersion"] = "3.2.1"
}
}
dependencies {
minecraft("com.mojang:minecraft:${minecraftVersion}")
mappings(loom.layered {
officialMojangMappings {
nameSyntheticMembers = true
}
parchment("org.parchmentmc.data:parchment-1.18.2:2022.05.22@zip")
})
modImplementation("net.fabricmc:fabric-loader:${loaderVersion}")
// Add each module as a dependency
listOf("fabric-api-base", "fabric-command-api-v1", "fabric-networking-v0", "fabric-lifecycle-events-v1", "fabric-resource-loader-v0").forEach {
modImplementation(fabricApi.module(it, fabricVersion))
}
// modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabricVersion}"
//
// modRuntime ("supercoder79:databreaker:0.2.9") {
// exclude module: "fabric-loader"
// }
// we shade the core classes directly into CC, so it gets remapped
shade(implementation(project(":CubicChunksCore")) {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements::class, LibraryElements.JAR))
}
isTransitive = false
})
debugCompile("org.lwjgl:lwjgl-vulkan:$lwjglVersion")
debugRuntime("org.lwjgl:lwjgl::$lwjglNatives")
include(implementation("com.github.OpenCubicChunks:dasm:9709b98")!!)
include(implementation("io.github.opencubicchunks:regionlib:0.63.0-SNAPSHOT")!!)
include(implementation("org.spongepowered:noise:2.0.0-SNAPSHOT")!!)
include(implementation("com.electronwill.night-config:core:3.6.0")!!)
include(implementation("com.electronwill.night-config:toml:3.6.0")!!)
extraTests(project(":CubicChunksCore")) {
targetConfiguration = "testArchivesOutput"
}
compileOnly("com.google.code.findbugs:jsr305:3.0.1")
testCompileOnly("com.google.code.findbugs:jsr305:3.0.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.0")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.0")
testImplementation("net.fabricmc:fabric-loader-junit:${loaderVersion}") // required for bootstrapping in unit tests
testImplementation("org.mockito:mockito-core:5.3.0")
// added at runtime, and fails to compile if used normally
"modTestRuntimeOnly"("supercoder79:databreaker:0.2.9")
testImplementation("org.hamcrest:hamcrest-junit:2.0.0.0")
testImplementation("org.hamcrest:hamcrest:2.2")
}
val jar: Jar by tasks
jar.apply {
dependsOn(configurations["shade"])
doFirst {
from({
project.configurations["shade"].map { if (it.isDirectory) it else zipTree(it) }.toList()
})
}
}
if (project.tasks.findByName("ideaSyncTask") != null) {
project.tasks.findByName("ideaSyncTask")!!.dependsOn("CubicChunksCore:assemble")
}
// unzipping subproject (CubicChunksCore) tests
val unzipTests by tasks.creating(Copy::class) {
outputs.upToDateWhen {
false
}
dependsOn(configurations["extraTests"])
from(configurations["extraTests"])
doFirst {
val testsFile = configurations["extraTests"].resolve().iterator().next()
from(zipTree(testsFile))
exclude(testsFile.name)
}
into(sourceSets.test.get().output.classesDirs.asPath)
}
// add explicit dependency to silence gradle warnings when building
tasks["checkstyleTest"].dependsOn(unzipTests)
val test: Test by tasks
test.apply {
minHeapSize = "512M"
maxHeapSize = "2048M"
dependsOn(unzipTests)
useJUnitPlatform()
// Always run tests, even when nothing changed.
dependsOn("cleanTest")
// Show test results.
testLogging {
events("passed", "skipped", "failed")
}
}
val processResources: ProcessResources by tasks
processResources.apply {
inputs.property("version", project.version)
filesMatching("fabric.mod.json") {
expand("version" to project.version)
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile::class) {
options.encoding = "UTF-8"
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
val sourcesJar by tasks.creating(Jar::class) {
dependsOn("classes")
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
jar.apply {
from("LICENSE")
manifest {
attributes(
"Specification-Title" to modId,
"Specification-Vendor" to "cubicchunks",
"Specification-Version" to "1", // We are version 1 of ourselves
"Implementation-Title" to project.name,
"Implementation-Version" to archiveVersion.get(),
"Implementation-Vendor" to "cubicchunks",
"Implementation-Timestamp" to Date().toInstant().toString(),
"MixinConnector" to "io.github.opencubicchunks.cubicchunks.mixin.CCMixinConnector",
"accessWidener" to "cubicchunks.accesswidener"
)
}
}
// configure the maven publication
publishing {
publications {
val mavenJava by creating(MavenPublication::class)
mavenJava.apply {
// add all the jars that should be included when publishing to maven
artifact("remapJar") {
builtBy("remapJar")
}
artifact(sourcesJar) {
builtBy("remapSourcesJar")
}
}
}
// select the repositories you want to publish to
repositories {
maven {
setUrl("file:///${project.projectDir}/mcmodsrepo")
}
}
}