-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.gradle
362 lines (311 loc) · 10.8 KB
/
build.gradle
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
import io.github.opencubicchunks.gradle.GeneratePackageInfo
buildscript {
dependencies {
classpath("com.google.code.gson:gson:2.8.5")
}
}
plugins {
id 'java-library'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '7.0.154'
id("io.github.opencubicchunks.javaheaders").version("1.2.8")
id("io.github.opencubicchunks.gradle.mcGitVersion")
id("io.github.opencubicchunks.gradle.mixingen")
}
version = mod_version
group = mod_group_id
base {
archivesName.set(mod_name)
}
javaHeaders {
setAcceptedJars(".*CubicChunksCore.*")
setConfig(file("javaHeaders.json"))
// setDebug(debugArtifactTransforms.toBoolean())
}
mcGitVersion {
snapshot = true
mcVersion = minecraft_version
setCommitVersion("570c0cbf0cdc15b8348a862a519d3399a943af9", "0.0")
}
sourceSets {
forge {
compileClasspath += sourceSets.main.compileClasspath
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.runtimeClasspath
runtimeClasspath += sourceSets.main.output
}
// create("gametest") {
// compileClasspath += configurations.compileClasspath
// compileClasspath += configurations.testCompileClasspath
// compileClasspath += sourceSets.main.output
// runtimeClasspath += configurations.runtimeClasspath
// runtimeClasspath += configurations.testRuntimeClasspath
// runtimeClasspath += sourceSets.main.output
// }
}
tasks.register("generatePackageInfo") {
group = "filegen"
doFirst {
for (final def sourceSet in project.sourceSets) {
GeneratePackageInfo.generateFiles(sourceSet)
}
}
}
tasks.register("genAll") {
group = "filegen"
dependsOn(generatePackageInfo, generateMixinConfigs)
}
mixinGen {
filePattern = "cubicchunks.mixins.%s.json"
defaultRefmap = "CubicChunks-refmap.json"
defaultPackagePrefix = "io.github.opencubicchunks.cubicchunks.mixin"
defaultCompatibilityLevel = "JAVA_17"
defaultMinVersion = "0.8"
config(sourceSets.main, "core") {
it.required = true
it.conformVisibility = true
it.injectorsDefaultRequire = 1
it.configurationPlugin = "io.github.opencubicchunks.cubicchunks.mixin.ASMConfigPlugin"
}
config(sourceSets.main, "access") {
it.required = true
it.conformVisibility = true
it.injectorsDefaultRequire = 1
}
config(sourceSets.forge, "forge") {
it.required = true
it.conformVisibility = true
it.injectorsDefaultRequire = 1
it.configurationPlugin = "io.github.opencubicchunks.cubicchunks.mixin.ASMConfigPlugin"
}
config(sourceSets.test, "test") {
it.required = true
it.conformVisibility = true
it.injectorsDefaultRequire = 1
}
/*
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"
}*/
}
base {
archivesName = mod_id
}
// Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17.
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
minecraft.accessTransformers.file rootProject.file('src/main/resources/META-INF/accesstransformer.cfg')
configurations {
libraries {}
implementation.extendsFrom libraries
extraTests
}
runs {
def args = [
"-XX:+IgnoreUnrecognizedVMOptions",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+AllowEnhancedClassRedefinition",
"-XX:-OmitStackTraceInFastThrow",
"-XX:+UseG1GC",
"-XX:G1NewSizePercent=20",
"-XX:G1ReservePercent=20",
"-XX:MaxGCPauseMillis=50",
"-XX:G1HeapRegionSize=32M",
"-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"
]
// applies to all the run configs below
configureEach {
jvmArguments args
// systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'forge.logging.console.level', 'debug'
modSource project.sourceSets.forge
dependencies {
runtime project.configurations.libraries
}
}
client {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
}
server {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
programArgument '--nogui'
}
gameTestServer {
systemProperty 'forge.enabledGameTestNamespaces', project.mod_id
}
data {
programArguments.addAll '--mod', project.mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath()
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
repositories {
mavenLocal()
maven { setUrl("https://oss.sonatype.org/content/repositories/snapshots/") }
maven { setUrl("https://jitpack.io") }
maven { setUrl("https://maven.fabricmc.net/") }
//maven {
// name = "Gegy"
// setUrl("https://maven.gegy.dev")
//}
}
dependencies {
implementation "net.neoforged:neoforge:${neo_version}"
implementation(project(":CubicChunksCore")) {
attributes {
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.class, LibraryElements.JAR))
}
transitive = false
}
extraTests(project(":CubicChunksCore")) {
targetConfiguration = "testArchivesOutput"
}
libraries("io.github.notstirred:dasm:2.0.1") {
transitive = false
}
libraries("io.github.opencubicchunks:regionlib:0.63.0-SNAPSHOT")
libraries("org.spongepowered:noise:2.0.0-SNAPSHOT")
// NeoForge does not yet support JUnit tests, so we use fabric loader for this instead.
testImplementation("net.fabricmc:fabric-loader-junit:0.15.3") // required for bootstrapping in unit tests
testImplementation("org.assertj:assertj-core:3.25.1")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.2")
testImplementation("org.mockito:mockito-core:5.2.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.9.2")
testImplementation("org.hamcrest:hamcrest-junit:2.0.0.0")
testImplementation("org.hamcrest:hamcrest:2.2")
}
tasks.withType(ProcessResources).configureEach {
var replaceProperties = [
minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
neo_version : neo_version, neo_version_range: neo_version_range,
loader_version_range: loader_version_range,
mod_id : mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
mod_authors : mod_authors, mod_description: mod_description,
]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml']) {
expand replaceProperties + [project: project]
}
}
// Force various tasks to run on intellij refresh
project.tasks.matching {
// Using prepareKotlinBuildScriptModel instead of ideaSyncTask as it was removed
it.name == "prepareKotlinBuildScriptModel"
}.forEach {
it.dependsOn("CubicChunksCore:assemble")
it.dependsOn(genAll)
}
// Ensure we always genAll on any run
processResources.dependsOn(genAll)
// unzipping subproject (CubicChunksCore) tests
tasks.register('unzipTests', Copy) {
outputs.upToDateWhen {
false
}
dependsOn(configurations.named("extraTests"))
from(configurations.named("extraTests"))
doFirst {
//noinspection ConfigurationAvoidance, we actually do want to resolve here
var testsFile = configurations["extraTests"].resolve().iterator().next()
from(zipTree(testsFile))
exclude(testsFile.name)
}
into(sourceSets.test.output.classesDirs.asPath)
}
test {
minHeapSize = "512M"
maxHeapSize = "2048M"
dependsOn(project.tasks.named("unzipTests"))
useJUnitPlatform {
excludeTags "longRunTest"
}
// Always run tests, even when nothing changed.
dependsOn("cleanTest")
// Show test results.
testLogging {
events("passed", "skipped", "failed")
}
jvmArgs("-ea", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true", "-Dmixin.checks.interfaces=true")
exclude "**/mixin*"
}
def longRunTest = tasks.register("longRunTest", Test) {
minHeapSize = "512M"
maxHeapSize = "2048M"
useJUnitPlatform {
includeTags "longRunTest"
}
// Show test results.
testLogging {
events("passed", "skipped", "failed")
}
jvmArgs("-ea", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true", "-Dmixin.checks.interfaces=true")
exclude "**/mixin*"
group = "Verification"
mustRunAfter project.tasks.named("unzipTests")
shouldRunAfter project.tasks.named("test")
}
tasks.named("check") {
dependsOn longRunTest
}
publishing {
publications {
register('mavenJava', MavenPublication) {
from components.java
}
}
repositories {
maven {
url "file://${project.projectDir}/repo"
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}