Error parsing TSRG file.
dualdragoon opened this issue · comments
I'm trying to build and whenever I do it fails complaining that it found an inline member before the class mapping for searge in output.tsrg specifically tsrg2 left right
which is the first line of the file. Is there something I need to do to keep that line from being there or is it a bug that it errors out on that line?
What's your ForgeGradle version? If it's 5, try downgrading it to 4.
I'm using the version of gradle and ForgeGradle that come with the newest Forge MDK. It uses Gradle 7.1.1 which is incompatible with older versions of ForgeGradle. Isn't there some way to just remove the first line from the file before the processor runs or better yet for the processor to skip the first line if it starts with that? I can't be the only person having this issue.
ForgeGradle 5 comes with a new TSRG format, adding the tsrg2 left right
in the beginning, and adding static
indications to static method mappings. Mixin's Annotation Processor doesn't know how to deal with those.
I fixed it with this workaround:
// Generate a fixed tsrg file after generating the default tsrg file
createMcpToSrg {
outputs.upToDateWhen {false}
doLast {
fixFG5TsrgForMixinAP(output.get().asFile, file("${buildDir}/fixMcpToSrg/output.tsrg"))
}
}
// Tell mixin to use the fixed TSRG file
mixin {
reobfSrgFile = file("${buildDir}/fixMcpToSrg/output.tsrg")
}
// Function that actually fixes the TSRG file
static def fixFG5TsrgForMixinAP(File inFile, File outFile) {
// Make directory if needed
outFile.parentFile.mkdirs()
try (Scanner scanner = new Scanner(inFile); PrintWriter out = new PrintWriter(outFile)) {
boolean firstLine = true
while (scanner.hasNextLine()) {
String next = scanner.nextLine()
// Skip first 'tsrg left right' header line
if (firstLine) {
firstLine = false
continue
}
// Skip 'static' indicators
if (next.trim() == "static") {
continue
}
// Export line otherwise
out.println(next)
}
}
}
See this issue: SpongePowered/Mixin#526