Gradle: Add decompile task to projects (#1273)
* Gradle: Add decompile task to projects * add ff as dependency rather than adding ti in buildsrc * smh smh smh smh smh * Add ff version in buildsrc build file This doesn't work in ext as it officially isn't part of the project * Add missing ''s
This commit is contained in:
@@ -33,7 +33,7 @@ ext {
|
||||
asm = '7.1'
|
||||
commonsCli = '1.4'
|
||||
discord = '1.1'
|
||||
fernflower = '20171017'
|
||||
fernflower = '07082019'
|
||||
findbugs = '3.0.2'
|
||||
gson = '2.8.5'
|
||||
guava = '28.0-jre'
|
||||
@@ -82,7 +82,7 @@ ext {
|
||||
|
||||
allprojects {
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'checkstyle'
|
||||
if (this.name != 'rs-client') apply plugin: 'checkstyle'
|
||||
|
||||
group = 'net.runelite'
|
||||
version = '1.5.33-SNAPSHOT'
|
||||
@@ -105,6 +105,7 @@ subprojects {
|
||||
apply plugin: 'java-library'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: "com.github.ben-manes.versions"
|
||||
apply plugin: 'fernflower'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
7
buildSrc/build.gradle
Normal file
7
buildSrc/build.gradle
Normal file
@@ -0,0 +1,7 @@
|
||||
repositories {
|
||||
maven { url "https://raw.githubusercontent.com/runelite-extended/maven-repo/master" }
|
||||
}
|
||||
dependencies {
|
||||
compile localGroovy()
|
||||
implementation group: 'net.runelite', name: 'fernflower', version: '07082019'
|
||||
}
|
||||
16
buildSrc/src/main/groovy/FernflowerPlugin.groovy
Normal file
16
buildSrc/src/main/groovy/FernflowerPlugin.groovy
Normal file
@@ -0,0 +1,16 @@
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.StopExecutionException
|
||||
|
||||
class FernflowerPlugin implements Plugin<Project> {
|
||||
void apply(Project project) {
|
||||
project.task('decompile', type: FernflowerTask) {
|
||||
it.dependsOn(project.tasks.jar)
|
||||
it.doFirst {
|
||||
if (!project.tasks.jar.didWork) {
|
||||
throw new StopExecutionException()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
32
buildSrc/src/main/groovy/FernflowerTask.groovy
Normal file
32
buildSrc/src/main/groovy/FernflowerTask.groovy
Normal file
@@ -0,0 +1,32 @@
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler
|
||||
|
||||
class FernflowerTask extends DefaultTask {
|
||||
List<String> extraArgs
|
||||
String inputJar
|
||||
String outputDir
|
||||
|
||||
@InputFile
|
||||
File getInputJar() {
|
||||
project.file(inputJar ?: project.buildDir.toString() + '/libs/' + project.getName() + '-' + project.version + '.jar')
|
||||
}
|
||||
|
||||
@OutputDirectory
|
||||
File getOutputDir() {
|
||||
project.file(outputDir ?: project.buildDir.toString() + '/decompiled-sources')
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
void decompile() {
|
||||
getOutputDir().mkdirs()
|
||||
def args = [getInputJar().toString(), getOutputDir().toString()]
|
||||
if (extraArgs) {
|
||||
args.addAll(extraArgs)
|
||||
}
|
||||
|
||||
ConsoleDecompiler.main(args as String[])
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
implementation-class=FernflowerPlugin
|
||||
@@ -44,3 +44,6 @@ classes.doLast() {
|
||||
File f = file("build/classes/java/main/Placeholder.class")
|
||||
f.delete()
|
||||
}
|
||||
|
||||
// tasks.build.dependsOn(tasks.decompile)
|
||||
// this is just here to show how this could be used
|
||||
Reference in New Issue
Block a user