-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.gradle
442 lines (400 loc) · 14.2 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
buildscript {
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath 'com.modrinth.minotaur:Minotaur:2.4.3'
classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
classpath "com.github.breadmoirai:github-release:2.4.1"
}
}
import java.nio.file.Files
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'io.github.juuxel.loom-quiltflower' version '1.6.0'
id 'maven-publish'
}
if (System.getenv("MODRINTH_TOKEN")) {
apply plugin: "com.modrinth.minotaur"
}
if (System.getenv("CURSE_TOKEN")) {
apply plugin: "com.matthewprenger.cursegradle"
}
if (System.getenv("GITHUB_TOKEN")) {
apply plugin: "com.github.breadmoirai.github-release"
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
def origVersion = project.version
version = project.version+"+1.18"
group = project.maven_group
repositories {
maven {
url 'https://repo.sleeping.town'
content {
includeGroup 'com.unascribed'
}
}
maven {
url 'https://maven.terraformersmc.com/releases'
content {
includeGroup 'com.terraformersmc'
}
}
maven {
url 'https://maven.ssf.tf/'
content {
includeGroup 'tf.ssf.sfort'
}
}
maven {
url 'https://maven.gegy.dev/releases'
content {
includeGroup 'io.github.queerbric'
}
}
maven {
url 'https://repo.fabricmc.net'
content {
includeGroup 'net.fabricmc'
includeGroup 'net.fabricmc.api'
}
}
}
dependencies {
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation fabricApi.module('fabric-api-base', project.fabric_version)
//Required by pridelib/modmenu
modImplementation fabricApi.module('fabric-resource-loader-v0', project.fabric_version)
modImplementation('io.github.queerbric:pridelib:1.1.0+1.17') {
transitive = false
}
modImplementation('com.terraformersmc:modmenu:3.1.0') {
transitive = false
}
modImplementation 'com.unascribed:ears-api:1.4.5'
modImplementation('tf.ssf.sfort:fscript:3.2.0+1.18.1') {
transitive = false
}
modImplementation(include('com.unascribed:lib39-deferral:1.1.1'))
modRuntimeOnly fabricApi.module('fabric-screen-api-v1', project.fabric_version)
annotationProcessor project(':ap')
implementation 'com.google.code.gson:gson:2.8.9'
}
loom.accessWidenerPath = file('src/main/resources/fabrication.accesswidener')
apply plugin: FabFeaturesPlugin
apply plugin: FabPagesPlugin
processResources {
inputs.property 'version', project.version
filesMatching('fabric.mod.json') {
expand 'version': project.version
}
dependsOn(fabGenFeatures)
}
sourceSets {
dummy {
compileClasspath += configurations.compileClasspath
}
main {
compileClasspath += dummy.output
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
jar {
doFirst {
StringBuilder bldr = new StringBuilder();
File dir = file('build/classes/java/main');
dir.eachFileRecurse(groovy.io.FileType.FILES, {
if (it.name.endsWith('.class')) {
bldr.append(it.getAbsolutePath().substring(dir.getAbsolutePath().length()+1))
bldr.append('\n')
}
})
file('build/tmp/classes.txt').text = bldr.toString();
Set<String> expectedFailThatFailsAutoFilter = Set.of(
'lambda$static$12com.unascribed.fabrication.mixin.f_balance.disable_elytra.MixinModelPredicateProviderRegistry',
'handleAttackEntity(Lnet/minecraft/class_1657;Lnet/minecraft/class_1937;Lnet/minecraft/class_1268;Lnet/minecraft/class_1297;Lnet/minecraft/class_3966;)Lnet/minecraft/class_1269;com.unascribed.fabrication.mixin.a_fixes.fix_charm_amethyst_dupe.MixinClearItemFrames',
'handleUseEntity(Lnet/minecraft/class_1657;Lnet/minecraft/class_1937;Lnet/minecraft/class_1268;Lnet/minecraft/class_1297;Lnet/minecraft/class_3966;)Lnet/minecraft/class_1269;com.unascribed.fabrication.mixin.a_fixes.fix_charm_amethyst_dupe.MixinClearItemFrames',
'processLoading;com.unascribed.fabrication.mixin.e_mechanics.obsidian_tears.MixinModelLoaderForge',
'fireRenderEntityItemcom.unascribed.fabrication.mixin.i_woina.drops.MixinItemEntityRendererObfuscate',
'processLoadingcom.unascribed.fabrication.mixin.e_mechanics.obsidian_tears.MixinModelLoaderForge',
'method_27884com.unascribed.fabrication.mixin.f_balance.disable_elytra.MixinModelPredicateProviderRegistry'
)
def lge = project.getExtensions().getByType(net.fabricmc.loom.api.LoomGradleExtensionAPI.class)
def mappings = lge.getMappingsProvider().getMappings()
Map<String, Mapp> toInter = new HashMap<>()
List<String> fabRefl = Files.readAllLines(file('build/tmp/fabReflToMap').toPath())
for (String f : fabRefl) {
if (f == null) continue
Mapp.Target toTarget = new Mapp.Target(f)
if (toInter.containsKey('FabRefl')) toInter.get('FabRefl').target.add(toTarget)
else toInter.put('FabRefl', new Mapp(new String[]{}, new String[]{}, new Mapp.Target[]{toTarget}))
}
List<String> toParse = Files.readAllLines(file('build/tmp/fabToRefMap').toPath())
for (int i=0; i+3<toParse.size(); i++){
String toInterKey = toParse.get(i)
Mapp toAdd = new Mapp(toParse.get(++i).split('\t'), toParse.get(++i).split('\t'), toParse.get(++i).split('\t'))
if (toInter.containsKey(toInterKey)) toInter.get(toInterKey).add(toAdd)
else toInter.put(toInterKey, toAdd)
}
Map<String, String> fieldMap = new HashMap<>()
Map<String, String> targetMap = new HashMap<>()
Map<String, String> methodMap = new HashMap<>()
Map<String, String> classMap = new HashMap<>()
for (def map : toInter.values()){
for (def cl : mappings.classes){
String clName = cl.getName('named')
String clNameRez = cl.getName('intermediary')
String dottedClName = clName.replace('/', '.')
if (map.mixin.contains(dottedClName)) {
for (def clMethod : cl.methods) {
for (String mthd : map.method) {
int col = mthd.indexOf(';')
int dot = mthd.indexOf('.')
if (col == -1 || dot < col && dot != -1) col = dot
int brc = mthd.indexOf('(')
if (brc == -1) continue
String desc = mthd.substring(brc)
String name = mthd.substring(col == -1 || brc<col ? 0 : col+1, brc)
if ((name.equals(clMethod.getName('named')) || name.equals(clMethod.getName('intermediary'))) && (desc.equals(clMethod.getDesc('named')) || desc.equals(clMethod.getDesc('intermediary')))) {
methodMap.put(clName+';'+name+desc, clMethod.getName('intermediary') + clMethod.getDesc('intermediary'))
}
}
}
}
for (Mapp.Target mapt : map.target) {
String target = mapt.self
int col = target.indexOf(';')
int dot = target.indexOf('.')
if (col == -1 || dot < col && dot != -1) col = dot
if (mapt.applicable.contains(dottedClName)){
classMap.put(clName, clNameRez)
int brc = target.indexOf('(')
if (brc == -1) {
int cindx = target.lastIndexOf(':')
String name = target.substring(col+1, cindx == -1 ? target.length() : cindx)
for (def clField : cl.fields) {
if (clField.getName('named').equals(name) || clField.getName('intermediary').equals(name)){
fieldMap.put(target, clField.getName('intermediary')+":"+clField.getDesc('intermediary'))
}
}
continue
}
String desc = target.substring(brc)
String name = target.substring(col+1, brc)
for (def clMethod : cl.methods) {
if ((clMethod.getName('named').equals(name) || clMethod.getName('intermediary').equals(name)) && (clMethod.getDesc('named').equals(desc) || clMethod.getDesc('intermediary').equals(desc))){
targetMap.put(target, clMethod.getName('intermediary')+clMethod.getDesc('intermediary'))
}
}
}
}
}
//basic <init> pass because #656
{
for (Mapp.Target mapt : map.target) {
String target = mapt.self
int col = target.indexOf(';')
int dot = target.indexOf('.')
if (col == -1 || dot < col && dot != -1) col = dot
int brc = target.indexOf('(')
if (brc == -1) {
continue
}
String desc = target.substring(brc)
String name = target.substring(col+1, brc)
if (!"<init>".equals(name)) continue
//TODO map desc
if (!"()V".equals(desc)) continue
String claz = target.substring(0, col)
for (def cl : mappings.classes) {
String clName = cl.getName('named')
if (claz.endsWith(clName)) {
targetMap.put(target, "<init>()V")
}
}
}
}
}
StringBuilder bldrRel = new StringBuilder()
Map<String, String> bldrAbs = new HashMap<>()
for (Map.Entry<String, Mapp> intr : toInter){
for (Mapp.Target tar : intr.value.target){
String s = tar.self
String ad = targetMap.get(s)
if (ad == null) ad = fieldMap.get(s)
if (ad != null) {
int col = s.indexOf(';')
int dot = s.indexOf('.')
if (col == -1 || dot < col && dot != -1) col = dot
bldrAbs.put(s, 'L'+classMap.get(s.substring(s.charAt(0) == 'L' as char ? 1 : 0, col))+';'+ad)
} else if (!s.isBlank() && !expectedFailThatFailsAutoFilter.contains(s+intr.key)
&& !s.startsWith("Ljava/lang/") && !s.startsWith("com/mojang/blaze3d/")
) {
logger.log(LogLevel.ERROR, "Failed to map "+s+" for "+intr.key)
}
}
boolean frst = true
StringBuilder bldrRelIntern = new StringBuilder()
for (String s : intr.value.method) {
boolean missedMthd = true
for (String c : intr.value.mixin) {
String set = methodMap.get(c.replace('.', '/')+';'+s)
if (set != null){
if (frst) frst = false;
else bldrRelIntern.append('\t')
bldrRelIntern.append(s).append(' ').append(set)
missedMthd = false
break
}
}
if (missedMthd && !s.isBlank() && !expectedFailThatFailsAutoFilter.contains(s+intr.key) && !s.equals("<init>")) {
logger.log(LogLevel.ERROR, "Failed to map "+s+" for "+intr.key)
}
}
if (!bldrRelIntern.isEmpty()) {
if (!bldrRel.isEmpty()) bldrRel.append('\n')
bldrRel.append(intr.key)
bldrRel.append('\n')
bldrRel.append(bldrRelIntern)
}
}
file('build/tmp/fabRelRefMap.txt').text = bldrRel.toString()
bldrRel = new StringBuilder()
for (Map.Entry<String, String> entry : bldrAbs) {
bldrRel.append(entry.key).append(' ').append(entry.value).append('\n')
}
file('build/tmp/fabAbsRefMap.txt').text = bldrRel.toString()
}
from 'LICENSE'
from 'build/tmp/classes.txt'
from 'build/tmp/fabRelRefMap.txt'
from 'build/tmp/fabAbsRefMap.txt'
}
class Mapp{
static class Target{
Target(String target){
int i = target.indexOf(' ');
if (i == -1){
this.self = target
this.applicable = new ArrayList<>()
} else {
this.self = target.substring(0, i)
this.applicable = target.substring(i).split(' ')
}
}
public String self
public List<String> applicable
}
void add(Mapp map){
this.mixin.addAll(map.mixin)
this.method.addAll(map.method)
this.target.addAll(map.target)
}
void add(String[] mixin, String[] method, String[] target){
for (String s : mixin) this.mixin.add(s)
for (String s : method) this.method.add(s)
for (String s : target) this.target.add(new Target(s))
}
void add(Target[] target){
for (Target s : target) this.target.add(s)
}
Mapp(String[] mixin, String[] method, String[] target){
this.mixin = mixin
this.method = method
this.target = new ArrayList<>()
for (String s : target) this.target.add(new Target(s))
}
Mapp(String[] mixin, String[] method, Target[] target){
this.mixin = mixin;
this.method = method;
this.target = target;
}
public List<String> mixin
public List<String> method
public List<Target> target
}
def mcVersions = [ '1.18.2' ]
def stability = 'release'
def mrLoaders = [ 'fabric', 'quilt' ]
def curseLoaders = [ 'Fabric', 'Quilt' ]
def curseProject = '414445'
def mcmodcnClassID = '3548'
def mcmodcnLoaders = '2,11'
def artifact = remapJar.archivePath
if (System.getenv("PUBLISH_FORGERY")) {
stability = 'beta'
mrLoaders = [ 'forge' ]
curseProject = '434087'
curseLoaders = [ 'Forge' ]
mcmodcnClassID = '3547'
mcmodcnLoaders = '1'
artifact = file(remapJar.archivePath.getPath().reverse().replaceFirst("fabrication".reverse(), "forgery".reverse()).reverse())
}
if (System.getenv("MODRINTH_TOKEN")) {
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = 'fabrication'
versionNumber = project.version
versionName = 'v'+origVersion
versionType = stability
changelog = file('changelog.md').text
uploadFile = artifact
gameVersions = mcVersions
loaders = mrLoaders
detectLoaders = false
}
}
if (System.getenv("CURSE_TOKEN")) {
curseforge {
apiKey = System.getenv("CURSE_TOKEN")
project {
id = curseProject
releaseType = stability
changelog = file('changelog.md')
changelogType = 'markdown'
for (def s : mcVersions) addGameVersion s
for (def s : curseLoaders) addGameVersion s
mainArtifact(artifact) {
displayName = '['+project.minecraft_version+'] v'+origVersion
}
}
options {
javaIntegration = false
forgeGradleIntegration = false
javaVersionAutoDetect = false
}
}
}
if (System.getenv("GITHUB_TOKEN")) {
githubRelease {
token System.getenv("GITHUB_TOKEN")
owner "unascribed"
repo "Fabrication"
tagName 'v'+origVersion
releaseName 'v'+origVersion
targetCommitish "3.0/1.18"
body file('changelog.md').text
draft false
prerelease false
releaseAssets artifact
allowUploadToExisting true
}
tasks.githubRelease.dependsOn remapJar
}
if (System.getenv("MCMODCN_COOKIE")) {
task mcmodcn(type: Exec) {
dependsOn remapJar
commandLine './mcmodcn-upload.sh', mcmodcnClassID, mcVersions[mcVersions.size()-1], mcmodcnLoaders, '', artifact.getPath()
}
}