forked from FabricMC/Mixin
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
426 lines (373 loc) · 12.6 KB
/
Copy pathbuild.gradle
File metadata and controls
426 lines (373 loc) · 12.6 KB
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
plugins {
id "me.modmuss50.remotesign" version "0.5.0"
id "dev.lukebemish.central-portal-publishing" version "0.1.7"
}
// Apply plugin
apply plugin: 'java-library'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'potemkin-modules'
// Default tasks
defaultTasks 'check', 'build'
// Basic project information
group = 'com.cleanroommc'
version = buildVersion
base {
archivesName = 'cleanmix'
}
// Extended project information
ext.projectName = 'CleanMix'
// Define variables
ext.asmVersion = project.hasProperty("asmVersion") ? asmVersion : '9.0'
ext.legacyForgeAsmVersion = project.hasProperty("legacyForgeAsmVersion") ? asmVersion : '5.0.3'
// Project repositories
repositories {
mavenCentral()
maven {
name = 'minecraft'
url = 'https://libraries.minecraft.net/'
}
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
// For modlauncher
name = 'neoforged'
url = 'https://maven.neoforged.net/releases'
}
}
sourceSets {
legacy {
ext.languageVersion = 8
ext.compatibility = '1.8'
}
cleanroom {
compileClasspath += main.output
ext.languageVersion = 8
ext.compatibility = '1.8'
}
main {
compileClasspath += legacy.output
ext.languageVersion = 8
ext.compatibility = '1.8'
}
ap {
compileClasspath += main.output
ext.languageVersion = 8
ext.compatibility = '1.8'
}
fernflower {
compileClasspath += main.output
ext.languageVersion = 8
ext.compatibility = '1.8'
ext.modularityExcluded = true
}
agent {
compileClasspath += main.output
ext.languageVersion = 8
ext.compatibility = '1.8'
}
example {
compileClasspath += main.output
compileClasspath += ap.output
ext.modularityExcluded = true
}
test {
ext.modularityExcluded = true
}
launchwrapper {
compileClasspath += main.output
ext.languageVersion = 8
ext.compatibility = '1.8'
}
modlauncher {
compileClasspath += main.output
ext.languageVersion = 8
ext.compatibility = '1.8'
}
modlauncher4 {
compileClasspath += main.output
compileClasspath += modlauncher.output
ext.languageVersion = 8
ext.compatibility = '1.8'
}
modlauncher9 {
ext.languageVersion = 16
compileClasspath += main.output
compileClasspath += modlauncher.output
}
modularity {
ext.languageVersion = 16
ext.modularityExcluded = true // don't add ourselves
}
modularityDummy {}
}
java {
modularity.inferModulePath = false
disableAutoTargetJvm()
// Minimum version of Java required
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
withSourcesJar()
withJavadocJar()
}
configurations {
exampleImplementation .extendsFrom implementation
fernflowerImplementation .extendsFrom implementation
launchwrapperImplementation .extendsFrom implementation
cleanroomImplementation .extendsFrom launchwrapperImplementation
agentImplementation .extendsFrom implementation
modlauncherImplementation .extendsFrom implementation
modlauncher9Implementation .extendsFrom modlauncherImplementation
modularityImplementation .extendsFrom modlauncher9Implementation
modularityCompileOnly .extendsFrom compileOnly
}
// Because Mixin aims to support a variety of environments, we have to be able to run with older versions of GSON and Guava that lack official module
// names. This means the same library may appear with multiple module names. We want to be able to link our module with either of these two at
// runtime, without having to have two versions of the library on our compile-time module path. To do this, we generate empty "potemkin" jars with
// *only* a module descriptor for the module we want to be able to compile against.
potemkinModules {
module 'com.google.gson'
module 'com.google.common'
}
// Project dependencies
dependencies {
def guava = 'com.google.guava:guava:21.0' // from mc1.12 onwards
def gson = 'com.google.code.gson:gson:2.2.4'
def asmTree = "org.ow2.asm:asm-tree:$asmVersion"
def ff = 'org.jetbrains:intellij-fernflower:1.2.1.16'
implementation guava
implementation gson
if (Float.parseFloat(asmVersion) < 6) {
implementation "org.ow2.asm:asm-debug-all:$asmVersion"
}
implementation asmTree
implementation "org.ow2.asm:asm-commons:$asmVersion"
implementation "org.ow2.asm:asm-util:$asmVersion"
// Annotation Processor
apImplementation asmTree
apImplementation guava
apImplementation gson
// Fernflower decompiler
fernflowerImplementation ff
// LegacyLauncher service
launchwrapperImplementation ('net.minecraft:launchwrapper:1.11') {
exclude module: 'lwjgl'
exclude module: 'asm-debug-all'
exclude module: 'jopt-simple'
}
modlauncherImplementation 'net.sf.jopt-simple:jopt-simple:5.0.4'
modlauncherCompileOnly 'org.apache.logging.log4j:log4j-core:2.0-beta9'
modlauncherImplementation ("cpw.mods:modlauncher:$legacyModlauncherVersion") {
exclude module: 'asm'
exclude module: 'asm-analysis'
exclude module: 'asm-commons'
exclude module: 'asm-tree'
exclude module: 'jopt-simple'
}
modlauncher4Implementation ("cpw.mods:modlauncher:$legacyModlauncherVersion") {
exclude module: 'asm'
exclude module: 'asm-analysis'
exclude module: 'asm-commons'
exclude module: 'asm-tree'
exclude module: 'jopt-simple'
}
modlauncher9Implementation ("cpw.mods:modlauncher:$modlauncherVersion") {
exclude module: 'jopt-simple'
}
modlauncher9Implementation 'cpw.mods:securejarhandler:2.1.24'
legacyImplementation "org.ow2.asm:asm-tree:$asmVersion"
modularityCompileOnly 'org.apache.logging.log4j:log4j-core:2.11.2'
}
javadoc {
exclude '**/throwables'
classpath += sourceSets.legacy.output
source sourceSets.ap.allJava
options.encoding = 'UTF-8'
exclude {
it.relativePath.file && it.relativePath.pathString =~ 'tools' && !(it.name =~ /SuppressedBy|package-info/)
}
options {
docTitle 'Welcome to the Mixin Javadoc'
overview 'docs/javadoc/overview.html'
addBooleanOption '-allow-script-in-comments', true
}
doLast {
copy {
from 'docs/javadoc/resources'
into outputDirectory
}
}
}
eclipse {
classpath {
containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
file.whenMerged {
// Can't include old modlauncher because it causes issues with modules
entries.removeAll { it.kind == 'lib' && it.path =~ ~/modlauncher-$legacyModlauncherVersion/ }
entries.removeAll { it.kind == 'src' && it.path =~ ~/modlauncher4/ }
entries.removeAll { it.kind == 'lib' && it.path =~ ~/log4j.*beta9/ }
// Mark everything else as a module
entries.findAll { it.kind == "con" && it.path =~ /gradleclasspathcontainer$/ }.each {
it.entryAttributes['module'] = 'true'
}
}
}
project {
resourceFilter {
appliesTo = 'FOLDERS'
type = 'EXCLUDE_ALL'
matcher {
id = 'org.eclipse.ui.ide.multiFilter'
arguments = '1.0-name-matches-false-false-buildSrc'
}
}
}
// Build service task outputs for test projects
autoBuildTasks compileModlauncher4Java, compileModlauncher9Java, compileLaunchwrapperJava
}
// Filter, process, and include resources
processResources {
// Include in final JAR
from 'LICENSE.txt'
}
// License header formatting
def validateHeaders = tasks.register("validateHeaders", org.spongepowered.asm.mixin.build.ValidateLicenseHeadersTasks) {
header = resources.text.fromFile("HEADER.txt")
source = sourceSets.collect { it.allJava }
}
tasks.check.dependsOn validateHeaders
checkstyle {
configProperties = [
"name" : project.name,
"organization": project.organization,
"url" : project.url,
"year" : project.inceptionYear
]
configFile = file("checkstyle.xml")
toolVersion = '10.17.0'
}
// Source compiler configuration
tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xlint:all', '-Xlint:-path', '-proc:none']
options.deprecation = true
options.encoding = 'utf8'
}
def modularityInputs = objects.fileCollection()
project.sourceSets.each { set -> {
if (set.ext.has("languageVersion") && JavaVersion.current().isJava9Compatible()) {
project.tasks[set.compileJavaTaskName].options.release = set.ext.languageVersion
}
if (set.ext.has("compatibility")) {
project.tasks[set.compileJavaTaskName].sourceCompatibility = set.ext.compatibility
project.tasks[set.compileJavaTaskName].targetCompatibility = set.ext.compatibility
}
def modularityExcluded = set.ext.has("modularityExcluded") && set.ext.modularityExcluded
if (!modularityExcluded) {
project.sourceSets.modularity {
compileClasspath += set.output
}
modularityInputs.from set.output
}
}}
compileModularityJava {
inputs.files(modularityInputs)
options.javaModuleVersion = project.version as String
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
'--patch-module', "org.spongepowered.mixin=${modularityInputs.collect { it.absolutePath }.join(File.pathSeparator)}"
]
}
}
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
// disable the crazy super-strict doclint tool in Java 8
options.addStringOption('Xdoclint:syntax', '-quiet')
}
}
tasks.named('jar', Jar) {
group 'build'
archiveClassifier = ''
[sourceSets.ap, sourceSets.agent, sourceSets.cleanroom, sourceSets.fernflower, sourceSets.launchwrapper, sourceSets.legacy, sourceSets.main].each { from it.output }
// JAR manifest configuration
manifest.attributes(
"Implementation-Title": project.name,
"Implementation-Version": project.version,
"Implementation-Vendor": url,
// for HotswapAgent
"Premain-Class": "org.spongepowered.tools.agent.MixinAgent",
"Agent-Class": "org.spongepowered.tools.agent.MixinAgent",
"Can-Redefine-Classes": true,
"Can-Retransform-Classes": true
)
}
tasks.register('thinJar', Jar) {
group 'build'
archiveClassifier = 'thin'
[sourceSets.agent, sourceSets.cleanroom, sourceSets.fernflower, sourceSets.launchwrapper, sourceSets.legacy, sourceSets.main].each { from it.output }
// JAR manifest configuration
manifest.attributes(
"Implementation-Title": project.name,
"Implementation-Version": project.version,
"Implementation-Vendor": url,
// for HotswapAgent
"Premain-Class": "org.spongepowered.tools.agent.MixinAgent",
"Agent-Class": "org.spongepowered.tools.agent.MixinAgent",
"Can-Redefine-Classes": true,
"Can-Retransform-Classes": true
)
}
tasks.named('sourcesJar', Jar) {
group 'build'
[sourceSets.ap, sourceSets.agent, sourceSets.cleanroom, sourceSets.fernflower, sourceSets.launchwrapper, sourceSets.legacy, sourceSets.main].each {
from it.java
from it.resources
}
archiveClassifier = 'sources'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.named('javadocJar', Jar) {
group 'build'
dependsOn 'javadoc'
from javadoc.destinationDir
archiveClassifier = 'javadoc'
}
tasks.named('assemble') {
dependsOn 'thinJar'
}
ext.excludePomDeps = [
'fernflower',
'jarjar',
'hamcrest-library',
'junit',
'mockito-core',
'mixin-asm-debug-all',
'log4j-core',
'guava',
'gson'
]
publishing {
publications {
developer(MavenPublication) { publication ->
from components.java
groupId = project.group
artifactId = project.base.archivesName.get()
version = project.buildVersion
artifact tasks.named('thinJar')
}
}
repositories {
maven {
name = 'Cleanroom'
url = project.findProperty('CleanroomRepo') ?: 'https://repo.cleanroommc.com/releases'
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
}