forked from Roadhog360/Et-Futurum-Requiem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
323 lines (276 loc) · 9.73 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
buildscript {
repositories {
mavenCentral()
gradlePluginPortal() // this line has to be after mavenCentral() or ForgeGradle breaks apart
maven {
name = "forge"
url = "https://maven.minecraftforge.net/"
}
maven {
url = "https://jitpack.io"
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.11'
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.2'
}
}
repositories {
maven {
name = "gt"
url = "https://gregtech.mechaenetia.com/"
}
maven {
name = "GTNH Maven"
url = "https://nexus.gtnewhorizons.com/repository/public/"
}
maven {
url 'https://jitpack.io'
}
}
apply plugin: 'forge'
apply plugin: "com.github.johnrengelman.shadow"
// Bump this every new code update after a version release, even if not releasing yet, that
// way SNAPSHOT's work properly as something like `2.1.2-SNAPSHOT` orders before `2.1.2 in
// SEMVER that gradle uses.
group = "ganymedes01.etfuturum"
archivesBaseName = "Et_Futurum_Requiem"
def modVersion = "2.6.0"
version = project.hasProperty("useCommitHashInVersion") ? getCommitVersion(modVersion) : modVersion
def buildAll = project.hasProperty("all")
def getCommitVersion(modVersion){
try {
def commitHashProc = "git rev-parse --short HEAD".execute()
commitHashProc.waitFor()
if(commitHashProc.exitValue() == 0){
def commitHash = commitHashProc.text.trim()
def commitTagProc = "git tag --points-at HEAD".execute()
commitTagProc.waitFor()
if(commitTagProc.exitValue() == 0){
def commitTag = commitTagProc.text.trim()
if(commitTag){
return modVersion // if the commit is tagged, assume it's a release
} else {
return modVersion + "-SNAPSHOT-" + commitHash
}
} else {
println commitTagProc.err.text
throw new Exception("git tag exited with non-zero return value")
}
} else {
println commitHashProc.err.text
throw new Exception("git rev-parse exited with non-zero return value")
}
} catch(Exception e){
println "Failed to get commit version: " + e.getMessage()
}
return modVersion // fallback
}
// Run `./gradlew clean` when the metadata changes, otherwise the in-game meta (ForgeGradle's substitution) will remain stale.
def authorList = ["\u00A79ganymedes01", "\u00A7bRoadhog360", "\u00A7aembeddedt", "\u00A7ajss2a98aj", "\u00A7amakamys", "\u00A7aKryptonCaptain"]
def meta = [
name: "Et Futurum Requiem", // hardcoded in Reference.java
version: modVersion,
commitVersion: version,
mcversion: "1.7.10",
credits: "\u00A7bDelirusCrux, AstroTibs",
authorList: authorList.join('", "'),
url: "\u00A77https://www.curseforge.com/minecraft/mc-mods/et-futurum-requiem",
description: "\u00A79Brings the future to now, for real this time.",
logoFile: "assets/etfuturum/logo.png"
]
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.bootClasspath = org.gradle.internal.jvm.Jvm.current().getJre().getHomeDir().toString() +"/lib/rt.jar"
compileJava {
options.encoding = "UTF-8"
}
configurations {
// By default only compileClasspath extends shadow, make runtime extend it too
compile.extendsFrom(shadow)
}
dependencies {
// Can use `compileOnly` instead of `compile` if you want to require it at build time,
// but not require it in `runClient`/`runServer`
compileOnly "thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev"
compileOnly "mcp.mobius.waila:Waila:1.5.11-RC2-NONEI_1.7.10:dev"
/** every file in libs/ gets forcibly compiled, please use another dir
compile files('libs/BaublesExpanded-2.1.2-dev.jar')
compile files('libs/CraftTweaker-1.7.10-3.1.0-legacy.jar')*/
compileOnly "team.chisel:Chisel:2.9.5.12:deobf"
compileOnly "team.chisel.ctmlib:CTMLib:MC1.7.10-1.4.1.5:deobf"
compileOnly "codechicken:NotEnoughItems:1.7.10-1.0.5.120:dev"
compileOnly "codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev"
compileOnly "codechicken:CodeChickenCore:1.7.10-1.0.7.47:dev"
compileOnly("com.github.GTNewHorizons:Angelica:1.0.0-alpha19:api") {
transitive = false
}
compileOnly("com.github.GTNewHorizons:lwjgl3ify:1.5.14:api") {
transitive = false
}
shadow('com.github.makamys:MCLib:0.3.7.5') {
exclude group: "codechicken"
}
}
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
replaceIn 'ganymedes01/etfuturum/lib/Reference.java'
meta.each { k, v -> replace "@${k.toUpperCase()}@", v }
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.properties meta
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand meta.collectEntries { k, v -> [k, v.replaceAll("\u00A7.", "")] } // strip formatting
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
jar {
// we disable the original jar task, and make shadowJar do the work instead
enabled = false
dependsOn shadowJar
}
// shadowJar is the new jar
shadowJar {
classifier = '' // use the same file name as the jar task
configurations = [project.configurations.shadow]
relocate 'makamys.mclib', 'ganymedes01.etfuturum.repackage.makamys.mclib'
exclude '**/LICENSE.txt'
manifest {
attributes(
'FMLAT': "etfuturum_at.cfg",
)
}
}
task shadowJarNoMixin(type: Jar) {
dependsOn shadowJar
classifier = ''
version += '+nomixin'
from(zipTree(tasks.shadowJar.archivePath)){
exclude "org/spongepowered/**"
exclude "META-INF/services/**"
exclude "mcmod.info" // we create a different mcmod.info in this task
}
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
def metaNoMixin = meta.clone()
// add +nomixin to the end of the version in mcmod.info
metaNoMixin['commitVersion'] = meta['commitVersion'] + '+nomixin'
expand metaNoMixin.collectEntries { k, v -> [k, v.replaceAll("\u00A7.", "")] } // strip formatting
}
manifest = tasks.shadowJar.manifest
}
task devJar(type: Jar) {
dependsOn shadowJar
classifier = 'dev'
// copy the contents of the main jar
from zipTree(tasks.shadowJar.archivePath)
manifest = tasks.shadowJar.manifest
}
task devJarNoMixin(type: Jar) {
dependsOn devJar
classifier = 'dev'
version += '+nomixin'
from zipTree(tasks.devJar.archivePath)
exclude "org/spongepowered/**"
exclude "META-INF/services/**"
manifest = tasks.shadowJar.manifest
}
if(buildAll) {
// we create dev jars by copying the output jars before they get obfuscated
reobf.dependsOn devJar
artifacts {
archives devJar, devJarNoMixin, shadowJarNoMixin
}
}
if (!hasProperty("mavenUsername")) {
ext.mavenUsername="${System.getenv().MAVEN_USERNAME}"
}
if (!hasProperty("mavenPassword")) {
ext.mavenPassword="${System.getenv().MAVEN_PASSWORD}"
}
if (!hasProperty("mavenURL")) {
ext.mavenURL="${System.getenv().MAVEN_URL}"
}
uploadArchives {
repositories {
mavenDeployer {
uniqueVersion = false
repository(url: mavenURL) {
authentication(userName: mavenUsername, password: mavenPassword)
}
}
}
}
//##########################################################################################################
//######################################## Mixin Part ################################################
//##########################################################################################################
//Add
//--tweakClass org.spongepowered.asm.launch.MixinTweaker --mixin mixins.etfuturum.json
//to your client and server program arguments if working in a dev environment.
def yourMixinConfig = 'mixins.etfuturum.json'
def refMapForYourConfig = 'mixins.etfuturum.refmap.json'
def relativePathToMixinAP = 'tools/mixin-0.8-SNAPSHOT.jar'
repositories {
maven {
name = "sponge"
url = "https://repo.spongepowered.org/maven/"
}
}
dependencies {
shadow('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
// Mixin includes a lot of dependencies that are too up-to-date
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
exclude module: 'commons-io'
exclude module: 'log4j-core'
}
}
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + refMapForYourConfig
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
shadowJar {
from refMap
manifest {
attributes.put("TweakClass", "org.spongepowered.asm.launch.MixinTweaker")
attributes.put("FMLCorePluginContainsFMLMod", true)
attributes.put("ForceLoadAsMod", true)
attributes.put("MixinConfigs", yourMixinConfig)
}
}
reobf {
addExtraSrgFile mixinSrg
}
afterEvaluate {
def fixedRelPathToAP = relativePathToMixinAP
if(fixedRelPathToAP.startsWith('./') || fixedRelPathToAP.startsWith('.\\')){
fixedRelPathToAP = fixedRelPathToAP.substring(2)
} else if(fixedRelPathToAP.startsWith('/') || fixedRelPathToAP.startsWith('\\')){
fixedRelPathToAP = fixedRelPathToAP.substring(1)
}
tasks.compileJava {
println "Path: " + projectDir.absolutePath
options.compilerArgs += [
// There's a bug in the AnnotationProcessor for 0.7.11 that will generate the annotations pointing to the parent class instead of subclass
// resulting in the mixin not being applied. This is fixed in 0.8, however 0.8 needs guava > 21.0, and minecraft ships with 17.0.
// So as a hacky workaround... ship with 0.7.11, but use the AP from 0.8 for compiling
"-processorpath", projectDir.absolutePath + '/' + fixedRelPathToAP,
"-processor", "org.spongepowered.tools.obfuscation.MixinObfuscationProcessorInjection,org.spongepowered.tools.obfuscation.MixinObfuscationProcessorTargets",
"-Xlint:-sunapi", "-XDenableSunApiLintControl", "-XDignore.symbol.file",
"-AreobfSrgFile=${tasks.reobf.srg}", "-AoutSrgFile=${mixinSrg}", "-AoutRefMapFile=${refMap}"
]
}
}
sourceSets {
main {
ext.refMap = refMapForYourConfig
}
}
runClient {
// Workaround for Mixin not detecting mod (https://github.com/SpongePowered/Mixin/issues/207)
// (Fixed in UniMix, so this should be removed if we ever switch to it.)
args("--mods=" + java.nio.file.Paths.get("$projectDir").resolve(minecraft.runDir).normalize().relativize(shadowJar.archivePath.toPath()))
}