118 lines
4.3 KiB
Groovy
118 lines
4.3 KiB
Groovy
import org.apache.tools.ant.filters.ReplaceTokens
|
|
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler
|
|
import java.nio.file.Files
|
|
import java.nio.file.Paths
|
|
import java.util.zip.ZipFile
|
|
|
|
plugins {
|
|
id "com.github.hauner.jarTest" version "1.0.1"
|
|
}
|
|
|
|
description = 'Deobfuscator'
|
|
|
|
def deobfuscatedJar = "${rootPath}/runescape-client/build/libs/rs-client-${project.version}.jar"
|
|
|
|
def unzipFile(String file, String dest)
|
|
{
|
|
def zipFile = new ZipFile(file)
|
|
|
|
zipFile.entries().each { it ->
|
|
def path = Paths.get(dest + File.separator + it.name)
|
|
if (it.directory)
|
|
{
|
|
Files.createDirectories(path)
|
|
}
|
|
else
|
|
{
|
|
def parentDir = path.getParent()
|
|
if (!Files.exists(parentDir))
|
|
{
|
|
Files.createDirectories(parentDir)
|
|
}
|
|
Files.copy(zipFile.getInputStream(it), path)
|
|
}
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
deobjars
|
|
}
|
|
|
|
dependencies {
|
|
deobjars group: 'net.runelite.rs', name: 'vanilla', version: rsversion
|
|
deobjars project(':rs-client')
|
|
|
|
implementation group: 'com.google.code.gson', name: 'gson', version: gson
|
|
implementation group: 'com.google.guava', name: 'guava', version: guava
|
|
implementation group: 'net.runelite', name: 'fernflower', version: fernflower
|
|
implementation group: 'org.ow2.asm', name: 'asm', version: asm
|
|
implementation group: 'org.ow2.asm', name: 'asm-util', version: asm
|
|
implementation group: 'org.slf4j', name: 'slf4j-api', version: slf4j
|
|
implementation project(':runelite-api')
|
|
implementation project(':runescape-api')
|
|
|
|
runtime group: 'org.slf4j', name: 'slf4j-simple', version: slf4j
|
|
|
|
testImplementation configurations.deobjars.dependencies
|
|
testImplementation group: 'junit', name: 'junit', version: junit
|
|
testImplementation group: 'org.mockito', name: 'mockito-core', version: mockito
|
|
}
|
|
|
|
processResources {
|
|
from file("src/main/resources/deob.properties"), {
|
|
filter(ReplaceTokens, tokens: [
|
|
"rs.version": rsversion.toString(),
|
|
"vanilla.jar": configurations.deobjars.find {it.name.startsWith("vanilla")}.toString().replace('\\', "/"),
|
|
"rs.client": configurations.deobjars.find {it.name.startsWith("rs-client")}.toString().replace('\\', "/")
|
|
])
|
|
}
|
|
}
|
|
processTestResources {
|
|
from file("src/test/resources/deob-test.properties"), {
|
|
filter(ReplaceTokens, tokens: [
|
|
"rs.client": configurations.deobjars.find {it.name.startsWith("rs-client")}.toString().replace('\\', "/"),
|
|
"rs.version": rsversion.toString(),
|
|
"vanilla.jar": configurations.deobjars.find {it.name.startsWith("vanilla")}.toString().replace('\\', "/")
|
|
])
|
|
}
|
|
}
|
|
|
|
task gamepackUpdate {
|
|
dependsOn ":deobfuscator:build"
|
|
dependsOn ":rs-client:build"
|
|
|
|
doLast {
|
|
def path = sourceSets.main.runtimeClasspath
|
|
def loader = new URLClassLoader(path.collect { f -> f.toURI().toURL() } as URL[])
|
|
def downloader = loader.loadClass('net.runelite.gamepack.Downloader')
|
|
def clientVersion = loader.loadClass('net.runelite.deob.clientver.ClientVersionMain')
|
|
def deob = loader.loadClass('net.runelite.deob.Deob')
|
|
def mappings = loader.loadClass('net.runelite.deob.updater.UpdateMappings')
|
|
|
|
String gamepack = downloader.gamepack()
|
|
int version = clientVersion.version(gamepack)
|
|
|
|
String gamepackVersion = gamepack.replace("gamepack.jar", "gamepack-" + version + ".jar")
|
|
String gamepackDeob = gamepack.replace("gamepack.jar", "gamepack-" + version + "-deob.jar")
|
|
String gamepackMappings = gamepack.replace("gamepack.jar", "gamepack-" + version + "-updated-mappings.jar")
|
|
String gamepackMappingsDecomp = gamepackMappings.replace(".jar", "-decomp")
|
|
String gamepackMappingsFern = gamepackMappingsDecomp + File.separator + gamepackMappings.split("/gamepack/")[1]
|
|
|
|
if (version == -1 || version == rsversion)
|
|
{
|
|
return
|
|
}
|
|
|
|
deob.main(gamepackVersion, gamepackDeob)
|
|
mappings.main(deobfuscatedJar, gamepackDeob, gamepackMappings)
|
|
|
|
new File(gamepackMappingsDecomp).mkdirs()
|
|
ConsoleDecompiler.main(gamepackMappings, gamepackMappingsDecomp)
|
|
|
|
unzipFile(gamepackMappingsFern, gamepackMappingsDecomp)
|
|
new File(gamepackMappingsFern).delete()
|
|
|
|
loader.close()
|
|
}
|
|
}
|