forked from QuiltMC/quilt-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
431 lines (365 loc) · 11.3 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
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
427
428
429
430
431
buildscript {
dependencies {
classpath "org.kohsuke:github-api:${project.github_api}"
classpath "com.guardsquare:proguard-gradle:${project.proguard_gradle}"
}
}
plugins {
id 'java'
id 'java-library'
id 'eclipse'
id 'maven-publish'
id 'org.quiltmc.gradle.licenser' version '1.1.+'
id 'org.quiltmc.loom' version '1.1.+' apply false
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
archivesBaseName = "quilt-loader"
version = project.quilt_loader
def ENV = System.getenv()
allprojects {
apply plugin: 'java-library'
apply plugin: 'eclipse'
if (ENV.SNAPSHOTS_URL) {
version = version + "-SNAPSHOT"
}
if (!ENV.GITHUB_ACTIONS) {
version = version + "+local"
}
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'Quilt'
url = 'https://maven.quiltmc.org/repository/release'
}
maven {
name = 'Quilt'
url = 'https://maven.quiltmc.org/repository/snapshot'
}
maven {
name = 'Unascribed'
url = 'https://repo.sleeping.town/'
}
mavenCentral() {
content {
excludeGroupByRegex "org.ow2.asm"
}
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/fabric/api/java', 'src/fabric/impl/java', 'src/fabric/legacy/java']
}
}
configurations {
include
implementation {
extendsFrom include
}
}
dependencies {
// Non-"include"d dependencies must be added to the LoaderLibrary class as well.
api "org.ow2.asm:asm:${project.asm}"
api "org.ow2.asm:asm-analysis:${project.asm}"
api "org.ow2.asm:asm-commons:${project.asm}"
api "org.ow2.asm:asm-tree:${project.asm}"
api "org.ow2.asm:asm-util:${project.asm}"
api("net.fabricmc:sponge-mixin:${project.sponge_mixin}") {
exclude module: 'launchwrapper'
exclude module: 'guava'
}
api "net.fabricmc:tiny-mappings-parser:${project.tiny_mappings_parser}"
api "net.fabricmc:tiny-remapper:${project.tiny_remapper}"
api "net.fabricmc:access-widener:${project.access_widener}"
/*include*/ api "org.quiltmc:quilt-json5:${project.quilt_json5}"
include "org.quiltmc:quilt-loader-sat4j:${project.quilt_loader_sat4j}"
include "com.electronwill.night-config:core:${project.night_config}"
include "com.electronwill.night-config:toml:${project.night_config}"
api "org.quiltmc:quilt-config:${project.quilt_config}"
// also must update in minecraft AND minecraft test
compileOnly "org.quiltmc.chasm:chasm:${project.quilt_chasm}"
compileOnly "org.quiltmc.chasm:chassembly:${project.quilt_chasm}"
shadow "com.electronwill.night-config:core:${project.night_config}"
shadow "com.electronwill.night-config:toml:${project.night_config}"
include "com.unascribed:flexver-java:${project.flexver}"
shadow "com.unascribed:flexver-java:${project.flexver}"
testCompileOnly "org.jetbrains:annotations:${project.annotations}"
// Unit testing
testImplementation(platform("org.junit:junit-bom:${project.junit_bom}"))
testImplementation("org.junit.jupiter:junit-jupiter")
}
test {
useJUnitPlatform()
}
processResources {
inputs.property "version", project.version
inputs.property "tiny_mappings_parser", project.tiny_mappings_parser
inputs.property "sponge_mixin", project.sponge_mixin
inputs.property "tiny_remapper", project.tiny_remapper
inputs.property "access_widener", project.access_widener
inputs.property "quilt_json5", project.quilt_json5
inputs.property "asm", project.asm
inputs.property "asm_analysis", project.asm
inputs.property "asm_commons", project.asm
inputs.property "asm_tree", project.asm
inputs.property "asm_util", project.asm
inputs.property "quilt_config", project.quilt_config
filesMatching("quilt.mod.json") {
expand "version": project.version
}
filesMatching(["quilt_installer.json", "fabric-installer.launchwrapper.json"]) {
expand(
"tiny_mappings_parser": project.tiny_mappings_parser,
"sponge_mixin": project.sponge_mixin,
"tiny_remapper": project.tiny_remapper,
"access_widener": project.access_widener,
"quilt_json5": project.quilt_json5,
"asm": project.asm,
"asm_analysis": project.asm,
"asm_commons": project.asm,
"asm_tree": project.asm,
"asm_util": project.asm,
"quilt_config": project.quilt_config,
)
}
}
java {
sourceCompatibility = 8
targetCompatibility = 8
withJavadocJar()
withSourcesJar()
}
compileJava {
options.release.set(8)
}
jar {
enabled = false
// Set the classifier to fix gradle task validation confusion.
archiveClassifier = "disabled"
}
test {
useJUnitPlatform()
}
shadowJar {
// Has stupid defaults, make our own
enabled = false
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
// Renaming in the shadow jar task doesnt seem to work, so do it here
task getSat4jAbout(type: Copy) {
dependsOn project.configurations.include
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from {
configurations.include.collect {
zipTree(it).matching {
include 'about.html'
}
}
}
rename 'about.html', 'org/quiltmc/loader/impl/lib/sat4j/about-sat4j.html'
into layout.buildDirectory.dir("sat4j")
}
task fatJar(type: ShadowJar, dependsOn: getSat4jAbout) {
from sourceSets.main.output
from project(":minecraft").sourceSets.main.output
from getSat4jAbout.destinationDir
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
manifest {
attributes (
"Main-Class": "net.fabricmc.loader.launch.server.FabricServerLauncher",
"Fabric-Loom-Remap": "false",
"Automatic-Module-Name": "org.quiltmc.loader"
)
}
archiveClassifier = "fat"
configurations = [project.configurations.include]
relocate 'org.quiltmc.loader.util.sat4j', 'org.quiltmc.loader.impl.lib.sat4j'
relocate 'com.electronwill', 'org.quiltmc.loader.impl.lib.electronwill'
relocate 'com.unascribed.flexver', 'org.quiltmc.loader.impl.lib.flexver'
//relocate 'org.quiltmc.json5', 'org.quiltmc.loader.impl.lib.json5'
exclude 'about.html'
exclude 'sat4j.version'
exclude 'META-INF/maven/org.ow2.sat4j/*/**'
outputs.upToDateWhen { false }
}
File proguardFile = file("build/libs/quilt-loader-${version}.jar")
import proguard.gradle.ProGuardTask
task proguardJar(type: ProGuardTask, dependsOn: fatJar) {
def classpath = project(":minecraft").configurations.compileClasspath
inputs.files(fatJar, classpath)
outputs.files(proguardFile)
outputs.upToDateWhen { false }
doFirst {
classpath.resolve().forEach {
libraryjars it
}
}
libraryjars JavaVersion.current().java9Compatible ? "${System.getProperty('java.home')}/jmods" : "${System.getProperty('java.home')}/lib/rt.jar"
injars fatJar.archiveFile
outjars proguardFile
configuration file("proguard.conf")
}
build.dependsOn proguardJar
jar {
enabled = false
// Set the classifier to fix gradle task validation confusion.
archiveClassifier = "disabled"
}
tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}
sourcesJar {
from sourceSets.main.allSource
from project(":minecraft").sourceSets.main.allSource
}
// useful for creating test mod jar
task testJar(type: Jar) {
archiveClassifier = "test"
from sourceSets.test.output
}
task copyJson() {
def inJson = file('build/resources/main/quilt_installer.json')
//def inLwJson = file('src/main/resources/fabric-installer.launchwrapper.json')
def outJson = file("build/libs/${archivesBaseName}-${version}.json")
//def outLwJson = file("build/libs/${archivesBaseName}-${version}.launchwrapper.json")
inputs.files (inJson, /*inLwJson*/)
outputs.files(outJson, /*outLwJson*/)
doLast {
outJson.text = inJson.text
//outLwJson.text = inLwJson.text
}
}
tasks.copyJson.dependsOn "processResources"
tasks.build.dependsOn "copyJson"
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
// Target JDK 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release.set(8)
}
}
javadoc {
options {
if (file("README.html").exists()) {
overview = "README.html"
}
source = "8"
encoding = 'UTF-8'
charSet = 'UTF-8'
memberLevel = JavadocMemberLevel.PACKAGE
links(
'https://asm.ow2.io/javadoc/',
'https://docs.oracle.com/javase/8/docs/api/',
'https://logging.apache.org/log4j/2.x/log4j-api/apidocs/'
)
// Disable the crazy super-strict doclint tool in Java 8
addStringOption('Xdoclint:none', '-quiet')
}
source sourceSets.main.allJava.srcDirs
classpath = sourceSets.main.compileClasspath + sourceSets.main.output // compile impl stuff for dep as well
include("**/api/**")
// workaround as one of the api stuff use that package
failOnError false
}
allprojects {
license {
rule project.rootProject.file("codeformat/FABRIC_MODIFIED_HEADER")
rule project.rootProject.file("codeformat/HEADER")
include '**/*.java'
// Exclude gson since it is google's code, we just modify and bundle it
exclude '**/lib/gson/*.java'
}
}
// Causes more trouble than its worth
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(proguardFile) {
builtBy proguardJar
}
artifact(sourcesJar)
artifact javadocJar
artifact(file('build/resources/main/quilt_installer.json')) {
builtBy processResources
builtBy copyJson
}
// artifact(file('src/main/resources/fabric-installer.launchwrapper.json')) {
// builtBy copyJson
// classifier = "launchwrapper"
// }
// Manually inject the dependencies into the final POM.
// This allows for use without Loom in projects that don't need it.
//
// This is done this way to avoid including dependencies that are
// shaded in, as Gradle seems to provide no clean way of excluding
// dependencies from the final POM.
//
// Note: This only uses the `api` configuration to determine what is
// fine to include, and does not respect exclusions. A more advanced
// implementation that excludes the `include` configuration from
// runtime & compile classpaths would likely prove to be better if
// Quilt ever needs to have dependencies that aren't to be shaded nor
// passed through to the application.
// TODO: disabled until Loom can properly handle this.
// pom.withXml {
// final def dependenciesNode = asNode().appendNode("dependencies")
//
// for (final def dep : configurations.api.allDependencies) {
// // Tests for an external dependency.
// // Provides a guarantee that the needed metadata is present.
// if (dep instanceof ExternalDependency) {
// // Inject the dependency metadata.
// final def dependencyNode = dependenciesNode.appendNode("dependency")
//
// dependencyNode.appendNode("groupId", dep.group)
// dependencyNode.appendNode("artifactId", dep.name)
// dependencyNode.appendNode("version", dep.version)
//
// // Note: If ever retrofitted to include the runtime classpath,
// // change this to use the runtime scope if the dependency is not
// // present in the compile classpath.
// dependencyNode.appendNode("scope", "compile")
// }
// }
// }
}
}
repositories {
if (ENV.MAVEN_URL) {
maven {
url ENV.MAVEN_URL
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
} else if (ENV.SNAPSHOTS_URL) {
maven {
url ENV.SNAPSHOTS_URL
credentials {
username ENV.SNAPSHOTS_USERNAME
password ENV.SNAPSHOTS_PASSWORD
}
}
} else {
mavenLocal()
}
}
}