forked from Shadows-of-Fire/GatewaysToEternity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
346 lines (307 loc) · 12.1 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
plugins {
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'net.neoforged.gradle' version '[6.0.18, 6.2)'
id 'org.parchmentmc.librarian.forgegradle' version '1.+'
id 'com.diffplug.eclipse.apt' version '3.42.2'
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT'
id 'net.darkhax.curseforgegradle' version '1.1.15'
}
base {
archivesName = "${fileName}-${mcVersion}"
}
java.toolchain.languageVersion = JavaLanguageVersion.of(project.properties.javaVersion)
minecraft {
mappings channel: 'parchment', version: project.properties.parchmentVersion
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
enableEclipsePrepareRuns = true
copyIdeResources = true
generateRunFolders = true
runs {
configureEach {
workingDirectory project.file('run')
property 'forge.logging.markers', ''
property 'forge.logging.console.level', 'debug'
mods {
"${modid}" {
source sourceSets.main
}
}
}
client = {
}
server = {
args "--nogui"
}
data = {
workingDirectory project.file('run-data')
args '--mod', "${modid}", '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
}
}
}
sourceSets.main.resources {
srcDir 'src/generated/resources'
}
repositories {
maven {
// CurseForge
url "https://www.cursemaven.com"
content {
includeGroup "curse.maven"
}
}
maven {
// Curios
url "https://maven.theillusivec4.top"
content {
includeGroupByRegex "top\\.theillusivec4.*"
}
}
maven {
// The One Probe
url "https://maven.k-4u.nl"
content {
includeGroup "mcjty.theoneprobe"
}
}
maven {
// Patchouli
url "https://maven.blamejared.com"
content {
includeGroup "vazkii.patchouli"
includeGroupByRegex "net\\.darkhax.*"
includeGroupByRegex "com\\.blamejared.*"
includeGroup "org.openzen.zencode"
includeGroup "mezz.jei"
}
}
maven {
// Shadows
url "https://maven.shadowsoffire.dev/releases"
content {
includeGroup "dev.shadowsoffire"
}
}
}
dependencies {
minecraft "net.neoforged:forge:${mcVersion}-${forgeVersion}"
if(project.mixin.toBoolean()) annotationProcessor "org.spongepowered:mixin:${mixinVersion}:processor"
if(project.hasProperty('placeboVersion')) implementation fg.deobf("dev.shadowsoffire:Placebo:${mcVersion}-${placeboVersion}")
if(project.hasProperty('jeiVersion')) implementation fg.deobf("mezz.jei:jei-${mcVersion}-forge:${jeiVersion}")
if(project.hasProperty('jadeFileId')) implementation fg.deobf("curse.maven:jade-324717:${jadeFileId}")
if(project.hasProperty('curiosVersion')) implementation fg.deobf("top.theillusivec4.curios:curios-forge:${curiosVersion}")
if(project.hasProperty('patchouliVersion')) implementation fg.deobf("vazkii.patchouli:Patchouli:${patchouliVersion}")
if(project.hasProperty('topVersion')) implementation fg.deobf(project.dependencies.create("mcjty.theoneprobe:theoneprobe:${topVersion}") {
transitive = false
})
if(project.hasProperty('bookshelfVersion')) compileOnly fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-${mcVersion}:${bookshelfVersion}")
if(project.hasProperty('gamestagesVersion')) compileOnly fg.deobf("net.darkhax.gamestages:GameStages-Forge-${mcVersion}:${gamestagesVersion}")
if(project.hasProperty('twilightFileId')) implementation fg.deobf("curse.maven:the-twilight-forest-227639:${twilightFileId}")
if(project.hasProperty('gatewaysVersion')) implementation fg.deobf("dev.shadowsoffire:GatewaysToEternity:${mcVersion}-${gatewaysVersion}")
if(project.hasProperty('attributeslibVersion')) implementation fg.deobf("dev.shadowsoffire:ApothicAttributes:${mcVersion}-${attributeslibVersion}")
if(project.hasProperty('crafttweakerVersion')) {
implementation fg.deobf("com.blamejared.crafttweaker:CraftTweaker-forge-${mcVersion}:${crafttweakerVersion}")
if(project.hasProperty('crafttweakerAPVersion')) {
annotationProcessor "com.blamejared.crafttweaker:Crafttweaker_Annotation_Processors:${crafttweakerAPVersion}"
}
}
}
mixin {
if (project.mixin.toBoolean()) {
config "${modid}.mixins.json"
add sourceSets.main, "${modid}.refmap.json"
}
}
tasks.named('processResources', ProcessResources).configure {
def replaceProperties = [
modGroup: modGroup,
modid: modid,
version: version,
modName: modName,
author: author,
desc: desc,
mcVersion: mcVersion,
javaVersion: javaVersion,
forgeVersion: forgeVersion
]
if (project.hasProperty('placeboVersion')) replaceProperties.put 'placeboVersion', placeboVersion
if (project.hasProperty('attributeslibVersion')) replaceProperties.put 'attributeslibVersion', attributeslibVersion
if (project.hasProperty('curiosVersion')) replaceProperties.put 'curiosVersion', curiosVersion
if (project.hasProperty('topVersion')) replaceProperties.put 'topVersion', topVersion
if (project.hasProperty('patchouliVersion')) replaceProperties.put 'patchouliVersion', patchouliVersion
inputs.properties replaceProperties
def resourceTargets = [
'META-INF/mods.toml',
'pack.mcmeta'
]
filesMatching(resourceTargets) {
expand replaceProperties
}
// Automatically populate mixins.json from the mixin package and rename to modid.mixins.json
filesMatching('mixins.json') {
def mixinFiles = []
def clientMixinFiles = []
def path = "${project.projectDir}/src/main/java/${modGroup}/${modid}/mixin".replaceAll('\\.', '/')
fileTree(path).visit { FileVisitDetails details ->
def name = details.file.path.replace('\\', '/')
name = name.substring(name.indexOf('mixin/') + 'mixin/'.length(), name.length())
if(name.endsWith('.java')) {
name = name.substring(0, name.length() - '.java'.length())
if(name.startsWith('client')) {
clientMixinFiles.add(name)
} else {
mixinFiles.add(name)
}
}
}
def mixins = ''
def clientMixins = ''
for (int i = 0; i < mixinFiles.size(); i++) {
def name = mixinFiles[i]
name = name.replaceAll('\\/', '.')
mixins += ' "' + name + '"'
if (i != mixinFiles.size() - 1) {
mixins += ',\n'
}
}
for (int i = 0; i < clientMixinFiles.size(); i++) {
def name = clientMixinFiles[i]
name = name.replaceAll('\\/', '.')
clientMixins += ' "' + name + '"'
if (i != clientMixinFiles.size() - 1) {
clientMixins += ',\n'
}
}
replaceProperties.put('mixins', mixins)
replaceProperties.put('clientMixins', clientMixins)
expand replaceProperties
name "${modid}.mixins.json".toString()
}
// Automatically populate coremods.json file from existing coremod js files in /coremods
filesMatching('META-INF/coremods.json') {
def names = []
fileTree("${project.projectDir}/src/main/resources/coremods").visit { FileVisitDetails details ->
def name = details.file.path.replace('\\', '/')
name = name.substring(name.indexOf('coremods'), name.length())
if(name.endsWith('.js')) {
names.add(name)
}
}
def coremods = ''
for (int i = 0; i < names.size(); i++) {
def name = names[i]
coremods += "\t\"${modid}_" + name.substring('coremods/'.length(), name.length() - 3) + '": "' + name + '"'
if (i != names.size() - 1) {
coremods += ',\n'
}
}
replaceProperties.put('coremods', coremods)
expand replaceProperties
}
}
tasks.named('jar', Jar).configure {
manifest {
attributes([
"Specification-Title": project.fileName,
"Specification-Vendor": project.author,
"Specification-Version": "1.0", // We are version 1 of ourselves
"Implementation-Title": project.fileName,
"Implementation-Version": project.version,
"Implementation-Vendor" : project.author,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"MixinConfigs": project.mixin.toBoolean() ? "${modid}.mixins.json" : ""
])
}
finalizedBy 'reobfJar'
}
java {
withSourcesJar()
// withJavadocJar()
}
publishing {
repositories {
maven {
name = "shadowsMaven"
url = "https://maven.shadowsoffire.dev/releases"
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
publications {
mavenJava(MavenPublication) {
groupId = "${modGroup}"
artifactId = "${fileName}"
version = "${mcVersion}-${version}"
pom.withXml {
def node = asNode()
if(node.dependencies.size() > 0)
node.remove(node.dependencies) // Remove deps, as they are all mappings-dependent and/or forge
}
from components.java
}
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
if (project.hasProperty('crafttweakerAPVersion')) {
options.compilerArgs << "-Acrafttweaker.processor.document.output_directory=${project.layout.buildDirectory.file('crtDocs').get().getAsFile()}"
}
}
tasks.withType(GenerateModuleMetadata) {
enabled = false // Can't figure out how to disable the dependencies block here, and it's wrong by default (it pulls deobf deps).
}
def getChangelogLink() {
def repo = ''
def proc = 'git config --get remote.origin.url'.execute();
proc.in.eachLine { line -> repo = line}
proc.err.eachLine { line -> println line }
proc.waitFor();
def branch = ''
proc = 'git rev-parse --abbrev-ref HEAD'.execute()
proc.in.eachLine { line -> branch = line }
proc.err.eachLine { line -> println line }
proc.waitFor()
// Remove ".git" and append /blob/branch/changelog.md
if (!repo.isBlank() && !branch.isBlank()) {
return repo.substring(0, repo.length() - 4) + '/blob/' + branch + '/changelog.md'
}
else {
return ''
}
}
// Splits a list of values separated by ', ' (comma + space).
def splitList(list) {
def split = list.split(', ')
assert split.length == list.count(',') + 1
return split
}
tasks.register('publishCurseForge', net.darkhax.curseforgegradle.TaskPublishCurseForge).configure {
if (project.hasProperty('curseforgeUploadToken')) {
apiToken = getProperty('curseforgeUploadToken')
disableVersionDetection()
def projectId = getProperty('curseforgeProjectId')
def mainFile = upload(projectId, jar)
mainFile.changelog = getChangelogLink()
mainFile.addModLoader(splitList("${modLoaders}"))
mainFile.addJavaVersion("Java ${javaVersion}")
mainFile.addGameVersion("${mcVersion}")
mainFile.releaseType = "${releaseType}"
if (project.hasProperty('requiredDeps')) {
mainFile.addRequirement(splitList("${requiredDeps}"))
}
if (project.hasProperty('optionalDeps')) {
mainFile.addOptional(splitList("${optionalDeps}"))
}
if (project.hasProperty('incompatibleDeps')) {
mainFile.addIncompatibility(splitList("${incompatibleDeps}"))
}
mainFile.withAdditionalFile(sourcesJar)
}
}
task publishAll() {
dependsOn publish
dependsOn publishCurseForge
}