-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
603 lines (518 loc) · 18.8 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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
import groovy.json.*
import io.franzbecker.gradle.lombok.task.DelombokTask
import java.util.regex.*
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
classpath "org.codehaus.groovy.modules.http-builder:http-builder:0.7.2"
}
}
plugins {
id "com.matthewprenger.cursegradle" version "1.4.0"
id "io.franzbecker.gradle-lombok" version "1.10"
id "com.github.ben-manes.versions" version "0.15.0"
id "thefireplace.en2ud" version "1.0.2"
}
apply plugin: "com.github.ben-manes.versions"
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "maven"
apply plugin: "maven-publish"
def getChangelog() {
Pattern pattern = Pattern.compile("^.+?\n-+\n\n((?:- .+?\n)+)");
Matcher match = pattern.matcher(file("CHANGELOG.md").text.replaceAll("\r", ""));
if (match.find()) {
String res = match.group(1);
return res.substring(0, res.length() - 1);
} else {
return "";
}
}
def getVersionType() {
def lower_version = version.toLowerCase();
if (lower_version.contains("beta") || lower_version.contains("rc"))
return "beta";
else if (lower_version.contains("alpha"))
return "alpha";
else
return "release";
}
def getVersionName() {
try {
def version;
def tmp = "git describe --tags --dirty=-SNAPSHOT".execute().text.trim().substring(1).split("-");
if (tmp.length <= 2) {
version = tmp.join("-");
} else {
def versions = tmp[0].split("\\.");
versions[2] = String.valueOf(versions[2].toInteger() + tmp[1].toInteger());
version = versions.join(".") + "-development";
if (tmp.length == 4)
version += "-" + tmp[3];
}
version = "${minecraft_version}-${version}";
if (mod_version_postfix.isEmpty())
return version;
else
return version.replaceFirst("(-\\d+\\.\\d+\\.\\d+)", "\$1-${mod_version_postfix}");
} catch(Exception e) {
println e
return "UNKNOWN-VERSION"
}
}
def signJar(archivePath) {
if (project.hasProperty("keyStoreAlias") && project.hasProperty("keyStore") && project.hasProperty("keyStorePass")) {
ant.signjar(
jar: archivePath,
alias: project.keyStoreAlias,
keystore: project.keyStore,
storepass: project.keyStorePass,
preservelastmodified: true
)
} else {
println "WARNING!!!\tCannot sign jar!"
}
}
def MainDirResources = fileTree(dir: file("."), includes: ["README.md", "LICENSE", "CHANGELOG.md"])
def jsonPatterns = ["mcmod.info", "**/*.json", "**/*.mcmeta"]
def pngPatterns = ["**/*.png"]
def commonManifest = { attributes "FMLAT": "BrainStoneMod_at.cfg" }
version = getVersionName()
group = "brainstonemod" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "BrainStoneMod"
allprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
minecraft {
version = "${minecraft_version}-${forge_version}"
runDir = "run"
replace '${version}', project.version
mappings = mapping_version
useDepAts = true
clientJvmArgs += "-Xmx3G"
serverJvmArgs += "-Xmx2G"
}
en2ud {
modid = "brainstonemod"
copyInvalidLines = true
}
repositories {
maven { // JEI, Natura, Mantle, TiCon
name "JEI"
url "http://dvs1.progwml6.com/files/maven"
}
maven { // EnderCore, EnderZoo, The One Probe, CTM
name "tterrag"
url "http://maven.tterrag.com"
}
maven { // EnderIO
name "tterrag"
url "http://maven2.tterrag.com"
}
maven { // Tesla
name "Tesla"
url "http://maven.mcmoddev.com"
}
maven { // ChickenBone's mods and Draconic Evolution
name "ChickenBone's"
url "http://chickenbones.net/maven"
}
maven { // Immersive Engeneering
name "Blamejared"
url "http://blamejared.com/maven"
}
maven { // Forestry
name "IC2"
url "http://maven.ic2.player.to"
}
maven { // JustEnoughResources
name "bintray-way2muchnoise"
url "https://dl.bintray.com/way2muchnoise/dev"
}
maven { // CoFH
name = "Covers Maven"
url = "http://maven.covers1624.net"
}
maven { // Industrial Foregoing
name = "dyonovan"
url = "http://dyonovan.com/maven2"
}
maven { // Forgelin
name = "Shadowfacts"
url "http://maven.shadowfacts.net"
}
maven { // ZeroCore
name "zerocore"
url "http://maven.zerono.it"
}
flatDir {
dirs "lib"
}
}
dependencies {
// External Mods
deobfProvided "team.chisel.ctm:CTM:MC${minecraft_version}-${ctm_version}"
deobfProvided ("com.brandon3055.draconicevolution:Draconic-Evolution:${minecraft_version}-${draconicEvolution_version}:universal") {
exclude module: "jei_${minecraft_version}"
exclude module: "jei_1.12"
exclude module: "OpenComputers"
}
deobfProvided "com.enderio.core:EnderCore:${minecraft_version}-${endercore_version}"
deobfProvided("com.enderio:EnderIO:${minecraft_version}-${enderio_version}") {
transitive = false
}
deobfProvided "info.loenwind.autoconfig:AutoConfig:${minecraft_version}-${autoConfig_version}"
deobfProvided "info.loenwind.autosave:AutoSave:${minecraft_version}-${autoSave_version}"
deobfProvided("net.sengir.forestry:forestry_${minecraft_version}:${forestry_version}") {
exclude module: "jei_${minecraft_version}"
exclude module: "jei_1.12"
}
deobfProvided "net.ndrei:tesla-core-lib:1.12.2-1.0.15.+"
// deobfProvided("com.buuz135.industrial.IndustrialForegoing:industrialforegoing:${minecraft_version}-${industrialForegoing_version}") {
// exclude module: "jei_${minecraft_version}"
// exclude module: "jei_1.12"
// exclude module: "RedstoneFlux"
// exclude module: "tesla-core-lib"
// }
deobfProvided "blusunrize:ImmersiveEngineering:${immersive_engineering_version}"
deobfProvided "mezz.jei:jei_${minecraft_version}:${jei_version}"
deobfProvided "jeresources:JustEnoughResources-${minecraft_version}:${justEnoughResources_version}"
deobfProvided "net.darkhax.tesla:Tesla-${minecraft_version}:${tesla_version}"
deobfProvided ("cofh:RedstoneArsenal:${minecraft_version}-${redstoneArsenal_version}:universal") {
exclude module: "jei_${minecraft_version}"
exclude module: "jei_1.12"
}
deobfProvided("cofh:CoFHCore:${minecraft_version}-${coFHCore_version}:universal") {
exclude module: "jei_${minecraft_version}"
exclude module: "jei_1.12"
}
deobfProvided("cofh:CoFHWorld:${minecraft_version}-${coFHWorld_version}:universal") {
exclude module: "jei_${minecraft_version}"
exclude module: "jei_1.12"
}
deobfProvided("cofh:RedstoneFlux:1.12-${redstoneFlux_version}:universal") {
exclude module: "jei_${minecraft_version}"
exclude module: "jei_1.12"
}
deobfProvided("cofh:ThermalFoundation:${minecraft_version}-${thermalFoundation_version}:universal") {
exclude module: "jei_${minecraft_version}"
exclude module: "jei_1.12"
}
deobfProvided("cofh:ThermalExpansion:${minecraft_version}-${thermalExpansion_version}:universal") {
exclude module: "jei_${minecraft_version}"
exclude module: "jei_1.12"
}
deobfProvided "codechicken:CodeChickenLib:1.12.2-3.2.2.+:universal"
deobfProvided "slimeknights.mantle:Mantle:1.12-${mantle_version}"
deobfProvided("slimeknights:TConstruct:${minecraft_version}-${tconstruct_version}") {
exclude module: "jei_${minecraft_version}"
}
deobfProvided("it.zerono.mods.zerocore:zerocore:1.12-${zerocore_version}") {
exclude module: "ComputerCraft"
}
// Local Mods
provided "lib:Baubles-1.12:+:deobf"
deobfProvided "lib:ExtremeReactors-${minecraft_version}:+"
deobfProvided "lib:industrialforegoing-${minecraft_version}:+"
deobfProvided "lib:Overlord-${minecraft_version}:+"
deobfProvided "lib:Cucumber-${minecraft_version}:+"
// Mapping outdated :/
deobfProvided "lib:MysticalAgriculture-${minecraft_version}:+"
}
lombok {
version = "1.16.20"
sha256 = "c5178b18caaa1a15e17b99ba5e4023d2de2ebc18b58cde0f5a04ca4b31c10e6d"
}
task delombok(type: DelombokTask) {
args("src/main/java", "-d", "build/sources/delomboked/java")
}
task formatJson {
doLast {
sourceSets.main.resources.srcDirs.each {
dir -> fileTree(dir: dir, includes: jsonPatterns).each {
File file -> file.text = JsonOutput.prettyPrint(file.text) + "\n"
}
}
}
}
task optimizePng {
doLast {
sourceSets.main.resources.srcDirs.each {
dir -> fileTree(dir: dir, includes: pngPatterns).each { File file ->
long size = file.length()
exec {
executable "optipng"
args "-q", "-o7", "-zm1-9", "-strip", "all", file
}
long newSize = file.length()
if (newSize < size)
System.out.format "Reduced File size of %s from %d bytes to %d bytes (reduced by %.2f%%)", file, size, newSize, ((double) (size - newSize)) / ((double) size) * 100.0
}
}
}
}
sourceMainJava {
source = sourceSets.main.allSource
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
// replace version and mcversion
expand "version": project.version, "mcversion": project.minecraft.version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
from MainDirResources
rename "(.+_at.cfg)", 'META-INF/$1'
// Minify json resources
doLast {
fileTree(dir: outputs.files.asPath, includes: jsonPatterns).each {
File file -> file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
}
}
}
task showVersion {
description "Displays the current version"
group "help"
compileJava.dependsOn showVersion
deobfCompileDummyTask.dependsOn showVersion
extractMcpMappings.dependsOn showVersion
doLast {
println version
def versionFile = new File(buildDir, '.version');
versionFile.getParentFile().mkdirs();
versionFile.text = version;
}
outputs.upToDateWhen { false }
}
task gitTag {
description "Tags the current version in git. Specify the version by passing \"-PtagVersion=version\""
group "help"
doLast {
def tagVersion
if ( project.hasProperty("tagVersion") ) {
tagVersion = project.tagVersion
} else {
tagVersion = "v" + version.split("-")[1]
}
exec {
executable "git"
args "tag", "-a", tagVersion, "-m", getChangelog()
}
}
}
jar {
manifest commonManifest
finalizedBy reobfJar
}
reobfJar {
doLast {
signJar(jar)
}
}
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = "deobf"
manifest commonManifest
doLast {
signJar(deobfJar.archivePath)
}
}
sourceJar {
doLast {
signJar(sourceJar.archivePath)
}
}
artifacts {
archives jar
archives deobfJar
archives sourceJar
}
task checkTranslations {
doLast {
boolean langs_ok = true
Map<String, String> map_en = new LinkedHashMap<String, String>()
(file("src/main/resources/assets/brainstonemod/lang/en_US.lang")).eachLine {
def (value1, value2) = it.tokenize( '=' )
if (value1 == null || value2 == null) {return}
map_en.put(value1, value2)
}
file("src/main/resources/assets/brainstonemod/lang/").eachFileMatch( ~".*\\.lang\$" ) { langfile ->
if (!langfile.getName().contains("en_US")) {
Map<String, String> map = new LinkedHashMap<String, String>()
File outfile = file(langfile.getName() + ".txt")
Writer outwriter = outfile.newWriter("UTF-8")
boolean lang_ok = true
outwriter.write("\n// Additional translations:\n")
outwriter << langfile.filterLine {
def (value1, value2) = it.tokenize( "=" )
if (value1 == null || value2 == null) {return false}
map.put(value1, value2)
if (map_en.containsKey(value1)) {
return false
} else {
lang_ok = false
return true
}
}
outwriter.append("\n// Missing translations:\n")
for (e in map_en) {
if (!map.containsKey(e.key)) {
outwriter.append(e.key + "=" + e.value + "\n")
lang_ok = false
}
}
outwriter.close()
if (lang_ok) {
outfile.delete()
} else {
println "Lang file " + langfile.getName() + " is not ok!"
println "Created translation report ${outfile}"
langs_ok = false
}
}
}
if(!langs_ok)
println "\nSome language files are not up to date. See log above!"
}
}
uploadArchives {
repositories {
mavenDeployer {
if (project.hasProperty("auradev_maven")) {
repository(url: "${-> auradev_maven}") {
authentication(userName: project.findProperty("maven_user"), password: project.findProperty("maven_password"))
}
} else if (project.hasProperty("local_maven")) {
repository(url: "file://${local_maven}")
}
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
project {
name project.archivesBaseName
packaging "jar"
description "Brain Stone Mod"
url "https://github.com/BrainStone/brainstone"
scm {
url "https://github.com/BrainStone/brainstone"
connection "scm:git:[email protected]:BrainStone/brainstone.git"
developerConnection "scm:git:[email protected]:BrainStone/brainstone.git"
}
issueManagement {
system "github"
url "https://github.com/BrainStone/brainstone/issues"
}
licenses {
license {
name "License"
url "https://raw.githubusercontent.com/BrainStone/brainstone/master/LICENSE"
distribution "repo"
}
}
developers {
developer {
id "brainstone"
name "The_BrainStone"
roles {
role "owner"
role "developer"
}
}
developer {
id "fireplace"
name "The_Fireplace"
roles {
role "developer"
}
}
}
contributors {
contributor {
name "Jobbel"
roles {
role "texturer"
role "conceptionist"
}
}
contributor {
name "Herr_Kermit"
roles {
role "texturer"
}
}
contributor {
name "Count Grimhart"
roles {
role "texturer"
role "translator"
}
}
}
}
}
}
}
}
curseforge {
apiKey = project.hasProperty("curseForgeApiKey")? project.curseForgeApiKey : "empty"
project {
id = "250836"
changelog = file("CHANGELOG.md")
changelogType = "markdown"
releaseType = getVersionType()
addGameVersion "${minecraft_version}"
addGameVersion "Java 8"
mainArtifact(jar) {
displayName = jar.archiveName.replace(".jar", "")
}
addArtifact(deobfJar) {
displayName = deobfJar.archiveName.replace(".jar", "")
changelog = "*This is a file for mod developers. If you don't know what to do with it, don't use it!*"
}
addArtifact(sourceJar) {
displayName = sourceJar.archiveName.replace(".jar", "")
changelog = "*This is a file for mod developers. If you don't know what to do with it, don't use it!*"
}
relations {
requiredLibrary "ctm"
optionalLibrary "baubles"
optionalLibrary "draconic-evolution"
optionalLibrary "ender-io"
optionalLibrary "environmental-tech"
optionalLibrary "extreme-reactors"
optionalLibrary "forestry"
optionalLibrary "industrial-foregoing"
optionalLibrary "immersive-engineering"
optionalLibrary "jei"
optionalLibrary "just-enough-resources-jer"
optionalLibrary "overlord"
optionalLibrary "tesla"
optionalLibrary "thermal-expansion"
optionalLibrary "thermal-foundation"
optionalLibrary "tinkers-construct"
//optionalLibrary "ex-nihilo-adscensio"
//optionalLibrary "minefactory-reloaded"
//optionalLibrary "thaumcraft"
}
}
}