gradle: gamepackUpdate (#1690)
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
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"
|
||||
@@ -6,6 +10,30 @@ plugins {
|
||||
|
||||
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
|
||||
}
|
||||
@@ -48,3 +76,42 @@ processTestResources {
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user