This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
build.subprojects.gradle
381 lines (340 loc) · 11.4 KB
/
build.subprojects.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
// Buildscript Dependencies
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = 'Bintray TeamFruit'
url = "https://dl.bintray.com/team-fruit/mods/"
}
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
classpath project.forgegradle
}
}
// Plugins
plugins {
id 'com.github.johnrengelman.shadow' version '2.0.1'
}
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: 'java'
// Configure Source Sets - Step1
sourceSets {
base_api {}
base_main {}
base_test {}
compat_api {}
compat_main {}
compat_test {}
universal_api {}
universal_main {}
universal_test {}
}
// Configure Source Sets - Step2
apply plugin: project.forgegradle_plugin
def fg_plugin = plugins.findPlugin project.forgegradle_plugin
// Configure Source Sets - Step3
sourceSets {
[
[src: api, base: base_api, bootstrap: bootstrap_api, compat: compat_api, universal: universal_api],
[src: main, base: base_main, bootstrap: bootstrap_main, compat: compat_main, universal: universal_main],
[src: test, base: base_test, bootstrap: bootstrap_test, compat: compat_test, universal: universal_test]
].each { s ->
s.src.java.srcDirs = ["../sources/default/src/${s.src.name}/java"]
s.src.resources.srcDirs = ["../sources/default/src/${s.src.name}/resources"]
s.base.java.srcDirs = ["../sources/base/src/${s.src.name}/java"]
s.base.resources.srcDirs = ["../sources/base/src/${s.src.name}/resources"]
s.bootstrap.java.srcDirs = ["./sources/bootstrap/src/${s.src.name}/java"]
s.bootstrap.resources.srcDirs = ["./sources/bootstrap/src/${s.src.name}/resources"]
s.compat.java.srcDirs = ["./sources/compat/src/${s.src.name}/java"]
s.compat.resources.srcDirs = ["./sources/compat/src/${s.src.name}/resources"]
s.universal.java.srcDirs = ["../sources/universal/src/${s.src.name}/java"]
s.universal.resources.srcDirs = ["../sources/universal/src/${s.src.name}/resources"]
s.base.compileClasspath += s.src.compileClasspath
s.base.runtimeClasspath += s.src.runtimeClasspath
s.bootstrap.compileClasspath += s.src.compileClasspath
s.bootstrap.runtimeClasspath += s.src.runtimeClasspath
s.compat.compileClasspath += s.src.compileClasspath
s.compat.runtimeClasspath += s.src.runtimeClasspath
s.universal.compileClasspath += s.src.compileClasspath
s.universal.runtimeClasspath += s.src.runtimeClasspath
s.src.compileClasspath += s.base.output
s.src.runtimeClasspath += s.base.output
s.bootstrap.compileClasspath += s.base.output
s.bootstrap.runtimeClasspath += s.base.output
s.compat.compileClasspath += s.base.output
s.compat.runtimeClasspath += s.base.output
s.universal.compileClasspath += s.base.output
s.universal.runtimeClasspath += s.base.output
s.universal.compileClasspath += s.compat.output
s.universal.runtimeClasspath += s.compat.output
}
}
// Fix compatibility issue between Gradle 4 and ForgeGradle 2.1
if (project.forgegradle.contains('1.2') || project.forgegradle.contains('2.1'))
if (gradle.startParameter.logLevel.compareTo(org.gradle.api.logging.LogLevel.LIFECYCLE) >= 0)
ant.lifecycleLogLevel = 'ERROR'
if (project.forgegradle.contains('2.1')) {
def levels = [:]
[tasks.makeStart, tasks.recompileMc]*.doFirst {
def level = gradle.startParameter.logLevel
if (level.compareTo(org.gradle.api.logging.LogLevel.LIFECYCLE) >= 0) {
levels.put(delegate, level)
gradle.startParameter.logLevel = org.gradle.api.logging.LogLevel.INFO
}
}*.doLast {
def level = levels.get(delegate)
if (level!=null)
gradle.startParameter.logLevel = level
}
}
// Configure Version
version = mod_version
// Configure Shade
configurations {
shade
compile.extendsFrom shade
}
// Configure Java Compile Options
[
compileJava, compileApiJava, compileTestJava,
compileBase_mainJava, compileBase_apiJava, compileBase_testJava,
compileBootstrap_mainJava, compileBootstrap_apiJava, compileBootstrap_testJava,
compileCompat_mainJava, compileCompat_apiJava, compileCompat_testJava,
compileUniversal_mainJava, compileUniversal_apiJava, compileUniversal_testJava
]*.options*.encoding = 'UTF-8'
sourceCompatibility = targetCompatibility = '1.8'
// Add Arguments for Eclipse
if (tasks.findByPath('makeEclipseCleanRunClient')!=null) {
tasks.makeEclipseCleanRunClient.doFirst {
setArguments '--username Kamesuta'
if (project.isProperty('extra_fmlcore'))
setJvmArguments "-Dfml.coreMods.load=${project.extra_fmlcore}"
}
}
// Configure Minecraft
minecraft {
if (project.forgegradle.contains('2.2'))
setSuppressVersionTest(true)
version = "${project.version_minecraft}-${project.version_forge}"
if (project.isProperty('version_mappings'))
mappings = project.version_mappings
if (!project.isProperty('run_location'))
runDir = 'run'
else
runDir = run_location.replace('{modid}', project.modid).replace('{mcversion}', project.version_minecraft)
replaceIn 'Reference.java'
replace '${modid}', project.modid
replace '${modname}', project.modname
replace '${version}', mod_version
replace '${mcversion}', project.version_minecraft
replace '${forgeversion}', project.version_forge
}
// Auto-Generated Directory
task setupSourceSets {
doLast {
sourceSets*.java.srcDirs*.each { it.mkdirs() }
sourceSets*.resources.srcDirs*.each { it.mkdirs() }
}
[tasks.eclipseClasspath, tasks.ideaModule]*.dependsOn 'setupSourceSets'
}
// Version Update Check
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property 'version', mod_version
inputs.property 'mcversion', project.version_minecraft
}
// Dependency Repositories
repositories {
jcenter()
maven {
name = 'CurseForge'
url = 'https://minecraft.curseforge.com/api/maven/'
}
maven {
name = 'Bintray TeamFruit'
url = "https://dl.bintray.com/team-fruit/mods/"
}
}
// Dependencies
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
shade fileTree(dir: 'libs/shade', include: '*.jar')
compile fileTree(dir: '../libs', include: '*.jar')
shade fileTree(dir: '../libs/shade', include: '*.jar')
if (project.name==mod_commonname) {
compile 'net.teamfruit:fmllegacydependency:1.0.5'
if (project.isProperty('extra_fmlcore'))
shade 'net.teamfruit:coremodlegacydependency:1.0.0'
}
}
// ReobfShadowJar for 1.7.10
if (!reobf.hasProperty('dependsOn')) {
reobf {
shadowJar { mappingType = 'SEARGE' }
}
} else {
task reobfShadowJar(dependsOn: 'genSrgs', type: net.minecraftforge.gradle.tasks.user.reobf.ReobfTask) {
exceptorCfg = fg_plugin.delayedFile net.minecraftforge.gradle.user.UserConstants.EXC_SRG
srg = fg_plugin.delayedFile net.minecraftforge.gradle.user.UserConstants.REOBF_SRG
fieldCsv = fg_plugin.delayedFile net.minecraftforge.gradle.user.UserConstants.FIELD_CSV
fieldCsv = fg_plugin.delayedFile net.minecraftforge.gradle.user.UserConstants.METHOD_CSV
mcVersion = fg_plugin.delayedString '{MC_VERSION}'
mustRunAfter 'test'
mustRunAfter 'shadowJar'
reobf.dependsOn 'reobfShadowJar'
reobf(tasks.shadowJar) { arg ->
def javaConv = project.convention.plugins.get 'java'
arg.classpath = javaConv.getSourceSets().getByName('main').compileClasspath
}
extraSrg = fg_plugin.extension.srgExtra
afterEvaluate {
if (fg_plugin.extension.decomp) {
deobfFile = tasks.deobfuscateJar.delayedOutput
recompFile = fg_plugin.delayedDirtyFile fg_plugin.srcDepName, null, 'jar'
}
}
}
reobf.dependsOn 'reobfShadowJar'
}
// SourceJar for 1.7.10
if (tasks.findByPath('sourceJar')==null) {
task sourceJar(dependsOn: 'classes', type: Jar) {
}
}
// Jar Manifest
ext.commonManifest = {
if (project.isProperty('extra_fmlcore'))
attributes 'FMLCorePlugin': project.extra_fmlcore
if (project.isProperty('extra_fmlmod'))
attributes 'FMLCorePluginContainsFMLMod': project.extra_fmlcore
if (project.isProperty('extra_fmlat'))
attributes 'FMLAT': project.extra_fmlat
// Prevent from CurseForge duplicate error
attributes 'ModVersion': mod_version_full
}
// Output Jar Universal
shadowJar.configurations = [project.configurations.shade]
shadowJar {
from sourceSets.main.output
from sourceSets.api.output
from sourceSets.base_main.output
from sourceSets.base_api.output
from sourceSets.bootstrap_main.output
from sourceSets.bootstrap_api.output
if (project.name==mod_commonname) {
tasks.reobfShadowJar.classpath += sourceSets.compat_main.output
tasks.reobfShadowJar.classpath += sourceSets.compat_api.output
} else {
from sourceSets.compat_main.output
from sourceSets.compat_api.output
}
from sourceSets.universal_main.output
from sourceSets.universal_api.output
classifier 'universal'
manifest commonManifest
}
// Output Jar Diff
jar {
from sourceSets.main.output
from sourceSets.api.output
from sourceSets.compat_main.output
from sourceSets.compat_api.output
classifier 'diff'
manifest commonManifest
}
tasks.jar.dependsOn 'shadowJar'
// Output Jar Source
sourceJar {
from sourceSets.main.allSource
from sourceSets.api.allSource
from sourceSets.base_main.allSource
from sourceSets.base_api.allSource
from sourceSets.bootstrap_main.allSource
from sourceSets.bootstrap_api.allSource
from sourceSets.compat_main.allSource
from sourceSets.compat_api.allSource
from sourceSets.universal_main.allSource
from sourceSets.universal_api.allSource
classifier 'sources'
manifest commonManifest
}
// Output Jar Dev
task devJar(dependsOn: 'classes', type: Jar) {
from sourceSets.main.output
from sourceSets.api.output
from sourceSets.base_main.output
from sourceSets.base_api.output
from sourceSets.bootstrap_main.output
from sourceSets.bootstrap_api.output
from sourceSets.compat_main.output
from sourceSets.compat_api.output
from sourceSets.universal_main.output
from sourceSets.universal_api.output
classifier 'dev'
manifest commonManifest
}
// Output Jar Api
task apiJar(dependsOn: 'classes', type: Jar) {
from sourceSets.api.output
from sourceSets.base_api.output
from sourceSets.bootstrap_api.output
from sourceSets.compat_api.output
from sourceSets.universal_api.output
classifier 'api'
manifest commonManifest
}
// Configure Destination Directory
[jar, shadowJar, devJar, sourceJar, apiJar]*.destinationDir = mod_artifacts_dir
// Output Jar
artifacts {
archives jar
archives shadowJar
archives devJar
archives sourceJar
archives apiJar
}
// Release CurseForge
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(tasks.curseforge)) {
assert sec_curseforge_key!=null, 'missing sec_curseforge_key'
assert project.isProperty('extra_curseforge_id'), 'missing extra_curseforge_id'
}
}
if (sec_curseforge_key!=null&&project.isProperty('extra_curseforge_id')) {
curseforge {
tasks.curseforge.enabled = !mod_autorelease && project.name!=mod_commonname
tasks.curseforge.dependsOn 'reobfShadowJar'
apiKey = sec_curseforge_key
project {
id = project.extra_curseforge_id
changelogType = 'markdown'
changelog = mod_changelog
releaseType = mod_releasetype
mainArtifact(shadowJar) {
displayName = "${shadowJar.baseName}-${shadowJar.version}"
}
[/*jar, */devJar, sourceJar, apiJar].each { jar ->
addArtifact(jar) {
displayName = "${jar.baseName}-${jar.version}-${jar.classifier}"
}
}
if (project.isProperty('extra_curseforge_dependency')) {
relations {
requiredLibrary project.extra_curseforge_dependency
}
}
}
}
} else
tasks.curseforge.enabled = false
// Configure Project Settings
['project.gradle'].each { f -> [rootProject, project].each { p -> def fs = p.file(f); if (fs.exists()) apply from: fs } }