After upgrading from 4.2 to 4.4.1 I noticed a new warning: ‘The TaskInternal.execute() method has been deprecated and is scheduled to be removed in Gradle 5.0.’, related to https://gitlab.ow2.org/asm/asm/blob/master/build.gradle#L226
I use this to postprocess the compiled classes in place. How can I do this without using execute()?
(Un?)related question: this postprocessing uses ASM, after it has been compiled. In other words, this code postprocesses itself. Currently I solve this circularity issue by compiling the code twice, see https://gitlab.ow2.org/asm/asm/blob/master/build.gradle#L156. Is there a way to avoid this double compilation? I guess this requires to not do the post processing in place (which could solve the first question), but I could not find an easy way to do this. The best I could get, which is not fully working and does not seem well designed, is something like this:
evaluationDependsOn(':tools:retrofitter')
sourceSets.main.output.classesDir = 'build/raw_classes/java/main'
sourceSets.test.compileClasspath -= files('build/raw_classes/java/main')
sourceSets.test.compileClasspath += files('build/classes/java/main')
sourceSets.test.runtimeClasspath -= files('build/raw_classes/java/main')
sourceSets.test.runtimeClasspath += files('build/classes/java/main')
task postprocess(type: JavaExec) {
classpath project(':tools:retrofitter').tasks.jar.outputs.files
main = 'org.objectweb.asm.tools.Retrofitter'
args 'build/raw_classes/java/main', 'build/classes/java/main'
}
jar {
exclude { files('build/raw_classes/java/main') }
include { files('build/classes/java/main') }
}
postprocess.dependsOn compileJava, ':tools:retrofitter:build'
classes.dependsOn postprocess