gradle: kts dsl (#1845)

* gradle: kts dsl

* deob: Fix tests

* gradle: Convert fernflower plugin to kotlin
This commit is contained in:
Owain van Brakel
2019-10-27 19:35:25 +01:00
committed by Ganom
parent a3667f10e3
commit b859cec91a
52 changed files with 1598 additions and 975 deletions

View File

@@ -1,117 +0,0 @@
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()
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id(Plugins.jarTest.first) version Plugins.jarTest.second
}
val deobjars = configurations.create("deobjars")
dependencies {
deobjars(group = "net.runelite.rs", name = "vanilla", version = ProjectVersions.rsversion.toString())
deobjars(project(":runescape-client"))
implementation(Libraries.gson)
implementation(Libraries.guava)
implementation(Libraries.fernflower)
implementation(Libraries.asmAll)
implementation(Libraries.asmUtil)
implementation(Libraries.slf4jApi)
implementation(project(":runelite-api"))
implementation(project(":runescape-api"))
runtime(Libraries.slf4jSimple)
testImplementation(deobjars)
testImplementation(Libraries.junit)
testImplementation(Libraries.mockitoCore)
}
tasks {
val tokens = mapOf(
"rs.version" to ProjectVersions.rsversion.toString(),
"vanilla.jar" to deobjars.find { it.name.startsWith("vanilla") }.toString().replace("\\", "/"),
"rs.client" to deobjars.find { it.name.startsWith("runescape-client") }.toString().replace("\\", "/")
)
"processResources"(ProcessResources::class) {
inputs.properties(tokens)
from("src/main/resources") {
include("deob.properties")
filter<ReplaceTokens>("tokens" to tokens)
}
}
"processTestResources"(ProcessResources::class) {
inputs.properties(tokens)
from("src/test/resources") {
include("deob-test.properties")
filter<ReplaceTokens>("tokens" to tokens)
}
}
}