-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
446 lines (392 loc) · 14.7 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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net/' }
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
mavenCentral()
maven {
url = "https://repo.spongepowered.org/maven"
}
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
}
}
plugins {
id 'net.ltgt.apt' version '0.10'
id "com.modrinth.minotaur" version "2.+"
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'se.bjurr.gitchangelog.git-changelog-gradle-plugin' version '1.56'
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'idea'
apply plugin: 'maven-publish'
ext.configFile = file("build.txt")
configFile.withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse(prop)
project.ext.hasConfig = { key ->
return config.isSet(key);
}
}
version = "${config.mod_version}"
group = "org.zeith.${config.mod_id}"
archivesBaseName = "${config.mod_id_fancy}-${config.minecraft_version}"
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
minecraft {
mappings channel: 'stable', version: '39-1.12'
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client {
workingDirectory project.file('run')
jvmArgs([
'-Dfml.coreMods.load=com.zeitheron.hammercore.asm.HCASM'
])
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
args([
"-username",
"Zeitheron"
])
}
server {
workingDirectory project.file('run/server')
jvmArgs([
'-Dfml.coreMods.load=com.zeitheron.hammercore.asm.HCASM'
])
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
}
}
}
configurations {
embed
implementation.extendsFrom(embed)
}
repositories {
maven { url = 'https://repo.spongepowered.org/repository/maven-public/' }
mavenCentral()
maven {
name = "Zeitheron Maven"
url = "https://maven.zeith.org"
}
maven {
url = "https://jitpack.io"
}
flatDir { dirs "libraries/${config.minecraft_version}/all" }
flatDir { dirs "libraries/${config.minecraft_version}/classpathOnly" }
flatDir { dirs "libraries/${config.minecraft_version}/runtimeOnly" }
}
dependencies {
implementation("net.minecraftforge:mergetool:0.2.3.3") { force = true }
minecraft 'net.minecraftforge:forge:1.12.2-' + config.forge_version
implementation "org.zeith.HammerLib:HammerLib-${config.minecraft_version}:${config.hl_version}"
////// UTILITY STUFF //////
// implementation 'java-oo:javac-oo-plugin:0.5'
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
compileOnly 'org.jetbrains:annotations:24.0.1'
///////////////////////////
def libraries = new File(file("libraries"), "${config.minecraft_version}")
if (!libraries.isDirectory()) libraries.mkdirs()
def libDir = new File(libraries, "all");
if (libDir.isDirectory()) {
libDir.eachFile { file ->
def splitPos = file.name.lastIndexOf("-")
def modartifact = file.name.substring(0, splitPos)
def modversion = file.name.substring(splitPos + 1, file.name.length() - 4)
dependencies {
implementation project.dependencies.create("_all:$modartifact:$modversion")
}
}
} else libDir.mkdir();
libDir = new File(libraries, "classpathOnly");
if (libDir.isDirectory()) {
libDir.eachFile { file ->
def splitPos = file.name.lastIndexOf("-")
def modartifact = file.name.substring(0, splitPos)
def modversion = file.name.substring(splitPos + 1, file.name.length() - 4)
dependencies {
compileOnly project.dependencies.create("_classpath:$modartifact:$modversion")
}
}
} else libDir.mkdir();
libDir = new File(libraries, "runtimeOnly");
if (libDir.isDirectory()) {
libDir.eachFile { file ->
def splitPos = file.name.lastIndexOf("-")
def modartifact = file.name.substring(0, splitPos)
def modversion = file.name.substring(splitPos + 1, file.name.length() - 4)
dependencies {
runtimeOnly project.dependencies.create("_runtime:$modartifact:$modversion")
}
}
} else libDir.mkdir();
}
def startTasks = gradle.startParameter.taskNames
def intellijIDE = (System.getProperty("idea.sync.active") == "true" || System.getProperty("idea.active") == "true") && !startTasks.contains("build") && !startTasks.contains("buildAndUploadMod") && !startTasks.contains("publishAllPublicationsToMavenRepository") && !startTasks.contains("publish") && !startTasks.contains("jar")
println "Running IntelliJ IDE: " + intellijIDE
task cleanReplaces(type: Delete) {
delete "build/sources/replaced"
}
if (tasks.contains(build) && !intellijIDE) {
task applyReplaces(type: Copy) {
from('src/main/java')
into 'build/sources/replaced'
filter { line ->
line.replace('required-after:hammercore', "required-after:hammercore@[${config.hl_version},)")
.replace("@VERSION@", "${config.mod_version}")
}
}
compileJava.dependsOn applyReplaces
sourceSets {
main {
java {
srcDirs = ["build/sources/replaced"]
}
}
}
}
processResources {
inputs.property "version", config.mod_version
inputs.property "mcversion", config.minecraft_version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
include 'pack.mcmeta'
expand 'version': config.mod_version, 'mcversion': config.minecraft_version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
exclude 'pack.mcmeta'
}
}
jar {
from(configurations.embed.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude 'LICENSE.txt', 'META-INF/MANIFEST.MF', 'META-INF/maven/**', 'META-INF/*.RSA', 'META-INF/*.SF'
}
manifest {
attributes([
"FMLAT" : "accesstransformer.cfg",
"Specification-Title" : "MusicLayer",
"Specification-Vendor" : "DragonForge",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : "MusicLayer",
"Implementation-Version" : config.mod_version,
"Implementation-Vendor" : "DragonForge",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
import net.minecraftforge.gradle.common.task.SignJar
task signJar(type: SignJar, dependsOn: jar) {
onlyIf {
System.env.MC_KS_PASS != null
}
keyStore = System.env.MC_KS_PATH
alias = System.env.MC_KS_ALIAS
storePass = System.env.MC_KS_PASS
keyPass = System.env.MC_KS_PASS
inputFile = jar.archivePath
outputFile = jar.archivePath
}
jar.finalizedBy('reobfJar')
publish.dependsOn('reobfJar')
build.dependsOn signJar
assemble.finalizedBy('signJar')
signJar.finalizedBy('cleanReplaces')
task deobfJar(type: Jar) {
archiveClassifier = 'deobf'
from sourceSets.main.output
manifest {
attributes(["Specification-Title" : config.mod_id,
"Specification-Vendor" : "Zeitheron",
"Specification-Version" : "1",
"Implementation-Title" : project.name,
"Implementation-Version" : archiveVersion,
"Implementation-Vendor" : config.mod_authors,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs" : "mixins.${config.mod_id}.json"
])
}
}
task srcJar(type: Jar, dependsOn: classes) {
from sourceSets.main.allJava
archiveClassifier = 'sources'
}
artifacts {
archives deobfJar
archives srcJar
}
modrinth {
token = System.env.MODRINTH_TOKEN != null ? System.env.MODRINTH_TOKEN : "NONE"
projectId = config.modrinth_project
versionNumber = config.mod_version
versionType = config.release_type
uploadFile = jar
gameVersions = [config.minecraft_version]
dependencies {
def mods = config.required_mods.split(";")
if (mods.length > 0 && (mods.length > 1 || !mods[0].isEmpty()))
for (final def one in mods) {
if (one.isBlank()) continue
if (one.startsWith("@")) {
def pars = one.substring(1).split(":", 2)
if (pars[0].equalsIgnoreCase("m")) {
required.project pars[1].trim()
}
} else
required.project one.trim()
}
mods = config.optional_mods.split(";")
if (mods.length > 0 && (mods.length > 1 || !mods[0].isEmpty()))
for (final def one in mods) {
if (one.isBlank()) continue
if (one.startsWith("@")) {
def pars = one.substring(1).split(":", 2)
if (pars[0].equalsIgnoreCase("m")) {
optional.project pars[1].trim()
}
} else
optional.project one.trim()
}
mods = config.incompatible_mods.split(";")
if (mods.length > 0 && (mods.length > 1 || !mods[0].isEmpty()))
for (final def one in mods) {
if (one.isBlank()) continue
if (one.startsWith("@")) {
def pars = one.substring(1).split(":", 2)
if (pars[0].equalsIgnoreCase("m")) {
incompatible.project pars[1].trim()
}
} else
incompatible.project one.trim()
}
mods = config.embedded_mods.split(";")
if (mods.length > 0 && (mods.length > 1 || !mods[0].isEmpty()))
for (final def one in mods) {
if (one.isBlank()) continue
if (one.startsWith("@")) {
def pars = one.substring(1).split(":", 2)
if (pars[0].equalsIgnoreCase("m")) {
embedded.project pars[1].trim()
}
} else
embedded.project one.trim()
}
}
}
curseforge {
apiKey = System.env.CURSEFORGE_TOKEN != null ? System.env.CURSEFORGE_TOKEN : "NONE"
project {
id = config.cf_project
changelogType = 'html'
changelog = ""
releaseType = config.release_type
addGameVersion config.minecraft_version
addGameVersion "Forge"
mainArtifact(jar) {
displayName = "[${config.minecraft_version}] ${config.mod_name} - ${config.mod_version}"
}
def reqDeps = new ArrayList()
def optDeps = new ArrayList()
def incompat = new ArrayList()
def embLibs = new ArrayList()
def mods = config.required_mods.split(";")
if (mods.length > 0 && (mods.length > 1 || !mods[0].isEmpty()))
for (final def one in mods) {
if (one.isBlank()) continue
if (one.startsWith("@")) {
def pars = one.substring(1).split(":", 2)
if (pars[0].equalsIgnoreCase("c")) {
reqDeps.add pars[1].trim()
}
} else
reqDeps.add one.trim()
}
mods = config.optional_mods.split(";")
if (mods.length > 0 && (mods.length > 1 || !mods[0].isEmpty()))
for (final def one in mods) {
if (one.isBlank()) continue
if (one.startsWith("@")) {
def pars = one.substring(1).split(":", 2)
if (pars[0].equalsIgnoreCase("c")) {
optDeps.add pars[1].trim()
}
} else
optDeps.add one.trim()
}
mods = config.incompatible_mods.split(";")
if (mods.length > 0 && (mods.length > 1 || !mods[0].isEmpty()))
for (final def one in mods) {
if (one.isBlank()) continue
if (one.startsWith("@")) {
def pars = one.substring(1).split(":", 2)
if (pars[0].equalsIgnoreCase("c")) {
incompat.add pars[1].trim()
}
} else
incompat.add one.trim()
}
mods = config.embedded_mods.split(";")
if (mods.length > 0 && (mods.length > 1 || !mods[0].isEmpty()))
for (final def one in mods) {
if (one.isBlank()) continue
if (one.startsWith("@")) {
def pars = one.substring(1).split(":", 2)
if (pars[0].equalsIgnoreCase("c")) {
embLibs.add pars[1].trim()
}
} else
embLibs.add one.trim()
}
if (reqDeps.size() > 0 || optDeps.size() > 0 || incompat.size() > 0 || embLibs.size() > 0) {
relations {
reqDeps.each { dep ->
requiredDependency dep
}
optDeps.each { dep ->
optionalDependency dep
}
incompat.each { dep ->
incompatible dep
}
embLibs.each { dep ->
embeddedLibrary dep
}
}
}
}
}
afterEvaluate {
if (!config.maven_url.isEmpty()) {
tasks["curseforge${config.cf_project}"].dependsOn.add(publish)
tasks["modrinth"].dependsOn.add(publish)
}
}
tasks.register('buildAndUploadMod') {
group = "upload"
dependsOn "curseforge${config.cf_project}", 'modrinth'
doLast {
println "Upload complete."
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = "${config.maven_group}"
artifactId = config.mod_id_fancy + "-" + config.minecraft_version
artifact jar
artifact srcJar
artifact deobfJar
}
}
repositories {
maven {
url config.maven_url
}
}
}