diff --git a/build.gradle b/build.gradle index 3917ff3..703217e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'io.izzel.arclight' -version '1.19' +version '1.20' repositories { mavenCentral() diff --git a/src/main/groovy/io/izzel/arclight/gradle/ArclightGradlePlugin.groovy b/src/main/groovy/io/izzel/arclight/gradle/ArclightGradlePlugin.groovy index 6f6d171..9f8070f 100644 --- a/src/main/groovy/io/izzel/arclight/gradle/ArclightGradlePlugin.groovy +++ b/src/main/groovy/io/izzel/arclight/gradle/ArclightGradlePlugin.groovy @@ -36,13 +36,36 @@ class ArclightGradlePlugin implements Plugin { project.configurations.implementation.extendsFrom(conf) def buildTools = project.file("${arclightExt.sharedSpigot ? project.rootProject.buildDir : project.buildDir}/arclight_cache/buildtools") def buildToolsFile = new File(buildTools, 'BuildTools.jar') - def downloadSpigot = project.tasks.create('downloadBuildTools', DownloadBuildToolsTask, { - it.output = buildToolsFile - }) - downloadSpigot.doFirst { - if (buildToolsFile.exists()) throw new StopExecutionException() + def downloadSpigot + if (project.rootProject.tasks.findByPath('downloadBuildTools')) { + downloadSpigot = project.rootProject.tasks.getByName('downloadBuildTools') + } else { + downloadSpigot = project.rootProject.tasks.create('downloadBuildTools', DownloadBuildToolsTask, { + it.output = buildToolsFile + }) + downloadSpigot.doFirst { + if (buildToolsFile.exists()) throw new StopExecutionException() + } + } + def buildSpigot + if (project.rootProject.tasks.findByPath('buildSpigotTask')) { + buildSpigot = project.rootProject.tasks.getByName('buildSpigotTask') + } else { + buildSpigot = project.rootProject.tasks.create('buildSpigotTask', BuildSpigotTask, project) + project.afterEvaluate { + buildSpigot.doFirst { + if (new File(buildTools, "spigot-${arclightExt.mcVersion}.jar").exists()) { + throw new StopExecutionException() + } + } + buildSpigot.configure { BuildSpigotTask task -> + task.buildTools = buildToolsFile + task.outputDir = buildTools + task.mcVersion = arclightExt.mcVersion + task.dependsOn(downloadSpigot) + } + } } - def buildSpigot = project.tasks.create('buildSpigotTask', BuildSpigotTask, project) def processMapping = project.tasks.create('processMapping', ProcessMappingV2Task) def remapSpigot = project.tasks.create('remapSpigotJar', RemapSpigotTask) def generateMeta = project.tasks.create('generateArclightMeta', Copy) @@ -57,17 +80,6 @@ class ArclightGradlePlugin implements Plugin { task.dependsOn(remapSpigot) } project.afterEvaluate { - buildSpigot.doFirst { - if (new File(buildTools, "spigot-${arclightExt.mcVersion}.jar").exists()) { - throw new StopExecutionException() - } - } - buildSpigot.configure { BuildSpigotTask task -> - task.buildTools = buildToolsFile - task.outputDir = buildTools - task.mcVersion = arclightExt.mcVersion - task.dependsOn(downloadSpigot) - } def extractSrg = project.tasks.getByName('extractSrg') as ExtractMCPData def createSrgToMcp = project.tasks.getByName('createSrgToMcp') as GenerateSRG processMapping.configure { ProcessMappingV2Task task -> diff --git a/src/main/groovy/io/izzel/arclight/gradle/tasks/ProcessMappingV2Task.groovy b/src/main/groovy/io/izzel/arclight/gradle/tasks/ProcessMappingV2Task.groovy index 5f66be0..d721e27 100644 --- a/src/main/groovy/io/izzel/arclight/gradle/tasks/ProcessMappingV2Task.groovy +++ b/src/main/groovy/io/izzel/arclight/gradle/tasks/ProcessMappingV2Task.groovy @@ -20,6 +20,7 @@ class ProcessMappingV2Task extends DefaultTask { private static final def PKG = [ 'it', 'org/apache', 'jline', 'org/codehaus', 'org/eclipse' ] + private static final Map KNOWN_WRONG_MAP = ['m_7870_': 'startDrownedConversion'] private File buildData private File inSrg @@ -63,8 +64,15 @@ class ProcessMappingV2Task extends DefaultTask { } def srgRev = srg.reverse() def finalMap = srgRev.merge(csrg).reverse() + Map seenNames = [:] finalMap.topLevelClassMappings.each { - it.methodMappings.each { m -> + if (!it.fullObfuscatedName.contains('/')) { + return + } + it.methodMappings.each { MethodMapping m -> + if (!m.hasDeobfuscatedName()) { + return + } def s = m.deobfuscatedName if (!s.startsWith('m_')) { def c = srgRev.getTopLevelClassMapping(m.parent.deobfuscatedName).get() @@ -79,10 +87,28 @@ class ProcessMappingV2Task extends DefaultTask { println('No mapping found for ' + m) } } + } else { + def old = seenNames[m.deobfuscatedName] + if (old) { + if ((old.length() > 2 || m.obfuscatedName.length() > 2) && old != m.obfuscatedName) { + if (old.length() > 2 && m.obfuscatedName.length() > 2) { + if (KNOWN_WRONG_MAP[m.deobfuscatedName] != m.obfuscatedName) { + println("Duplicate [$old, ${m.obfuscatedName}] -> ${m.deobfuscatedName} in ${m.parent.fullDeobfuscatedName}") + } + } else { + seenNames[m.deobfuscatedName] = m.obfuscatedName.length() > old.length() ? m.obfuscatedName : old + } + } + } else { + seenNames[m.deobfuscatedName] = m.obfuscatedName + } } } } new File(outDir, 'bukkit_srg.srg').withWriter { + PKG.each { pkg -> + it.writeLine("PK: org/bukkit/craftbukkit/libs/$pkg $pkg") + } new TSrgWriter(it) { def remapper = new Remapper() { @Override @@ -106,7 +132,8 @@ class ProcessMappingV2Task extends DefaultTask { @Override protected void writeMethodMapping(MethodMapping mapping) { this.writer.println(String.format("\t%s %s %s", - mapping.getObfuscatedName(), remapper.mapMethodDesc(mapping.getObfuscatedDescriptor()), + seenNames.getOrDefault(mapping.getDeobfuscatedName(), mapping.getObfuscatedName()), + remapper.mapMethodDesc(mapping.getObfuscatedDescriptor()), mapping.getDeobfuscatedName())) } }.write(finalMap)