-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.gradle
330 lines (283 loc) · 9.94 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
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import net.minecraftforge.gradle.common.tasks.SignJar
import org.gradle.work.Incremental
plugins {
id 'net.neoforged.gradle' version '6.0.+'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.6'
id 'eclipse'
}
version = '0.4.1-b' + version_buildnumber
group = 'com.igteam.immersivegeology' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'ImmersiveGeology'
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
jar.enabled = true
tasks.withType(Jar) {
// Enable ZIP64 for regular Jar task
zip64 true
}
sourceSets {
main {
resources {
srcDirs = [
"$rootDir/src/main/resources",
"$rootDir/src/generated/resources",
]
}
}
datagen {
compileClasspath += main.compileClasspath
runtimeClasspath += main.runtimeClasspath
compileClasspath += main.output
runtimeClasspath += main.output
}
}
def version_replaces = [
'version' : project.version,
'build_number' : version_buildnumber,
'mc_version' : version_minecraft,
'forge_version': version_forge,
'jei_version' : version_jei,
'mod_license' : mod_license,
'mod_name' : mod_name,
'mod_authors' : mod_authors,
'mod_description': mod_description
]
def jsonPatterns = ["**/*.json", "**/*.mcmeta"]
processResources {
duplicatesStrategy = DuplicatesStrategy.FAIL
inputs.properties(version_replaces)
filesMatching("META-INF/mods.toml") {
expand version_replaces
}
exclude ".cache"
//Minify json resources
doLast {
fileTree(dir: getOutputs().getFiles().getAsPath(), includes: jsonPatterns).each {
File file -> file.setText(JsonOutput.toJson(new JsonSlurper().parse(file, 'UTF-8')))
}
}
}
// When using "Run using IntelliJ" (the only option with well-working hotswapping) the used "resources" directory is
// different from the one used by gradle/the processResources task
task copyModsTomlForIntelliJ(type: Copy) {
from processResources.destinationDir
into "$projectDir/out/production/resources"
include "META-INF/mods.toml"
}
copyModsTomlForIntelliJ.dependsOn processResources
afterEvaluate {
// prepareRuns doesn't exist before afterEvaluate
prepareRuns.dependsOn copyModsTomlForIntelliJ
}
minecraft {
mappings channel: 'parchment', version: "$version_parchment-$version_minecraft"
accessTransformers {
file('src/main/resources/META-INF/accesstransformer.cfg')
}
runs {
client {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', 'SCAN'
property 'forge.enabledGameTestNamespaces', 'immersivegeology'
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
ideaModule project.name + ".gametest"
mods {
immersivegeology {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', ''
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'immersivegeology'
// Disable GUI by default, the IDE console can be used to enter commands
arg '-nogui'
mods {
immersivegeology {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
// Recommended logging data for a userdev environment
property 'forge.logging.markers', ''
// Recommended logging level for the console
property 'forge.logging.console.level', 'debug'
property 'fml.earlyprogresswindow', 'false'
args '--mod', 'immersivegeology', '--all', '--output', file('src/generated/resources/'), '--validate',
'--existing', sourceSets.main.resources.srcDirs[0]
ideaModule project.name+".datagen"
mods {
immersivegeology {
source sourceSets.main
source sourceSets.datagen
}
}
}
gameTestServer {
workingDirectory project.file('run')
property 'forge.logging.markers', ''
property 'forge.logging.console.level', 'debug'
property 'forge.enabledGameTestNamespaces', 'immersivegeology'
ideaModule project.name + ".gametest"
mods {
immersivegeology {
source sourceSets.main
}
}
}
}
}
repositories {
maven { // JEI & BlockModelSplitter
name 'Jared maven'
url 'https://maven.blamejared.com/'
}
maven {
// tfc
url = 'https://www.cursemaven.com'
content {
includeGroup "curse.maven"
}
}
maven {//Curse maven, in case some other maven goes offline and for mods that don't have a maven
url "https://cfa2.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven { // CC-Tweaked
url 'https://squiddev.cc/maven/'
content {
includeGroup("cc.tweaked")
includeModule("org.squiddev", "Cobalt")
}
}
}
dependencies {
minecraft "net.neoforged:forge:${version_minecraft}-${version_forge}"
compileOnly fg.deobf("mezz.jei:jei-1.20.1-forge-api:${version_jei}")
compileOnly fg.deobf("mezz.jei:jei-1.20.1-common-api:${version_jei}")
implementation fg.deobf("mezz.jei:jei-1.20.1-forge:${version_jei}")
implementation fg.deobf("curse.maven:immersive-engineering-231951:5224387")
// Ad Astra
// implementation fg.deobf("curse.maven:resourceful-config-714059:5020441")
// implementation fg.deobf("curse.maven:botarium-704113:5486070")
// implementation fg.deobf("curse.maven:resourceful-lib-570073:5568216")
// implementation fg.deobf("curse.maven:ad-astra-635042:4894852")
// Quark
// implementation fg.deobf("curse.maven:zeta-968868:5597406")
// implementation fg.deobf("curse.maven:quark-243121:5594847")
//
// //BoP
// implementation fg.deobf("curse.maven:terrablender-563928:5068218")
// implementation fg.deobf("curse.maven:biomes-o-plenty-220318:4617259")
// TFC
implementation fg.deobf("vazkii.patchouli:Patchouli:$version_minecraft-$version_patchouli-FORGE")
implementation fg.deobf("curse.maven:terrafirmacraft-302973:5943050")
datagenImplementation("blusunrize.immersiveengineering:ImmersiveEngineering:${version_ie}:datagen")
annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
def customGradle = rootProject.file('custom.gradle');
if (customGradle.exists()) {
apply from: customGradle;
}
task signJar(type: SignJar) {
onlyIf {
project.hasProperty('keyStore')
}
if (project.hasProperty('keyStore')) {
keyStore = project.keyStore
alias = project.storeAlias
storePass = project.storePass
keyPass = project.storePass
inputFile = shadowJar.archiveFile
outputFile = shadowJar.archiveFile
} else {
logger.warn("No key store found, not signing the output jar\n")
}
}
build.dependsOn signJar
afterEvaluate {
reobfJar.enabled = true
}
task datagenJar(type: Jar, dependsOn: datagenClasses) {
archiveClassifier = 'datagen'
from sourceSets.datagen.output
manifest {
attributes "FMLModType": "GAMELIBRARY"
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
from sourceSets.datagen.allSource
}
artifacts {
archives sourcesJar
archives datagenJar
}
//Minimize/optimize all png files, requires optipng on the PATH
// Credits: BrainStone
void minimizePNGFile(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%%)\n",
file, size, newSize, ((double) (size - newSize)) / ((double) size) * 100.0)
}
}
task optimizePng {
def pngPatterns = ["**/*.png"]
doLast {
//Ensure the logo is minimized (we add this file to each jar)
//Minimize any PNGs in the source sets
for (dir in sourceSets.main.resources.srcDirs) {
fileTree(dir: dir, includes: pngPatterns).each { minimizePNGFile(it) }
}
}
}
mixin {
add sourceSets.main, "${modid}.refmap.json"
config "${modid}.mixins.json"
}
// Running this is equivalent to running genIntellijRuns, but it exists before afterEvaluate
task genIntellijRunsDummy {}
task speedUpPreRun {
doLast {
for (String s : new String[]{"Client", "Server", "Data"}) {
ant.replace(
file: ".idea/runConfigurations/run"+s+".xml",
// prepareRunX is prepareRuns + compile, but compiling is already handled by IntelliJ
token: "prepareRun"+s,
value: "prepareRuns"
)
}
}
}
tasks.withType(Task) {
if (it.name == "genIntellijRuns") {
it.finalizedBy speedUpPreRun
genIntellijRunsDummy.dependsOn it
} else if (it.name == "runServer") {
it.standardInput = System.in
}
}
idea.project.settings.taskTriggers {
afterSync genIntellijRunsDummy
}