* 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
32 lines
924 B
Groovy
32 lines
924 B
Groovy
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[])
|
|
}
|
|
} |