Merge vanilla pre-decompile annotations with Forge's post-patching. Fixes #4769 Crash detail classes causing class not found errors.

This commit is contained in:
LexManos 2018-03-23 20:42:33 -07:00
parent 9d8bf87e93
commit f908c2e449
1 changed files with 51 additions and 5 deletions

View File

@ -24,7 +24,7 @@ repositories {
}
apply plugin: "maven"
apply plugin: "net.minecraftforge.gradle.patcher"
def patcher_plugin = plugins.apply('net.minecraftforge.gradle.patcher')
apply plugin: "net.minecraftforge.gradle.launch4j"
minecraft.version = "1.12.2"
@ -122,18 +122,65 @@ def extraTxts = [
if (project.hasProperty('forgeJenkinsPass'))
extraTxts += changelog
import groovy.json.JsonSlurper;
import groovy.json.JsonBuilder;
task extractAnnotationsVanilla(type: net.minecraftforge.gradle.tasks.TaskExtractAnnotationsText, dependsOn: deobfuscateJar) {
jar = deobfuscateJar.outJar
output = 'build/vanilla_annotations.json'
output = 'build/vanilla_annotations_raw.json'
doLast { //Re-dump it so it's in groovy's sorted order. Because I like being able to do diffs against things.
def json = new JsonSlurper().parseText(file(output).text)
file(output).write(new JsonBuilder(json).toPrettyString())
}
}
task reobfToSRG(type: net.minecraftforge.gradle.patcher.TaskReobfuscate, dependsOn: reobfuscate) {
srg = patcher_plugin.delayedFile('{CACHE_DIR}/de/oceanlabs/mcp/mcp_{MAPPING_CHANNEL}/{MAPPING_VERSION}/{MC_VERSION}/srgs/mcp-srg.srg')
exc = reobfuscate.exc
preFFJar = reobfuscate.preFFJar
methodsCsv = reobfuscate.methodsCsv
fieldsCsv = reobfuscate.fieldsCsv
addLibs reobfuscate.libs
inJar = patcher_plugin.delayedFile('{BUILD_DIR}/localCache/Forge/recompiled.jar')
outJar = 'build/forge_srg.jar'
}
task extractAnnotationsForgeSRG(type: net.minecraftforge.gradle.tasks.TaskExtractAnnotationsText, dependsOn: reobfToSRG) {
jar = reobfToSRG.outJar
output = 'build/forge_annotations.json'
doLast { //Re-dump it so it's in groovy's sorted order. Because I like being able to do diffs against things.
def json = new JsonSlurper().parseText(file(output).text)
json.entrySet().removeIf{e -> (!e.key.startsWith('net/minecraft/') && !e.key.startsWith('net/minecraftforge/')) || e.key.endsWith('/package-info')}
file(output).write(new JsonBuilder(json).toPrettyString())
}
}
task fixAnnotationsJson(dependsOn: [extractAnnotationsVanilla, extractAnnotationsForgeSRG, genPatches]) {
inputs.file(extractAnnotationsVanilla.output)
inputs.file(extractAnnotationsForgeSRG.output)
outputs.file('build/vanilla_annotations.json')
doLast {
def json_vanilla = new JsonSlurper().parseText(file(extractAnnotationsVanilla.output).text) as TreeMap
def json_forge = new JsonSlurper().parseText(file(extractAnnotationsForgeSRG.output).text) as TreeMap
def start = minecraft.projects.forge.patchDir.absolutePath.length()
file(minecraft.projects.forge.patchDir).traverse(type: groovy.io.FileType.FILES, nameFilter: {nf -> nf.endsWith('.java.patch')}) { f ->
def cls = f.absolutePath.substring(start+1).replace('\\', '/').replace('.java.patch', '')
json_vanilla.entrySet().removeIf{e -> e.key == cls || e.key.startsWith(cls + '$')}
json_forge.entrySet().stream().filter{e -> e.key == cls || e.key.startsWith(cls + '$')}.forEach{e -> json_vanilla.put(e.key, e.value)}
}
json_forge.entrySet().stream().filter{e -> e.key.startsWith('net/minecraftforge/')}.forEach{e -> json_vanilla.put(e.key, e.value)}
outputs.files.singleFile.write(new JsonBuilder(json_vanilla).toPrettyString())
}
}
outputJar {
classifier = 'universal'
from extraTxts
from(extractAnnotationsVanilla){
from(fixAnnotationsJson){
into 'META-INF'
}
dependsOn extractAnnotationsVanilla
dependsOn fixAnnotationsJson
// add crowdin locales
from { crowdin.getDidWork() ? zipTree(crowdin.output) : null}
@ -320,7 +367,6 @@ uploadArchives {
// HELPER METHODS
import groovy.json.JsonSlurper;
String getServerClasspath(File file)
{