Hello,
I have a small plugin adding SourceSets in some occasion. In Gradle 3.x the groovy code for that plugin was:
def container = project.getConvention().getPlugin(JavaPluginConvention).sourceSets
// omitted for brevity: check that the name is not already taken
def sourceSet = container.create name
// omitted for brevity: set compileClasspath, runtimeClasspath, srcDir and resource dir
// I don't want classes bundled with all classes, so I'll set a classesDir in SourceSetOutput
sourceSet.output.classesDir = "somewhere" as File
So far it worked perfectly when built with Gradle 3.x and ran on project using Gradle 3.x
Now that Gradle 4 is out, with an updated default SourceSetOutput class directory, I wish to update this plugin in a manner that applying it on a project while running Gradle 3.x produces the old behavior (i.e. put classes in separate dir), and applying it on a project while running Gradle 4.x produces the default behavior.
I change the code as follow:
boolean oldGradle = (gradle.gradleVersion <=> '4.0') < 0
if (oldGradle) {
sourceSet.output.classesDir = "somewhere" as File
}
I run my integration tests using the gradle test kit and they fail with a Gradle 3 runner, but work with Gradle 4 runner.
Error is java.lang.NoSuchMethodError: org.gradle.api.tasks.SourceSetOutput.setClassesDir(Ljava/io/File;)V
I remove the @CompileStatic annotation on my plugin class and everything works, both with Gradle 3 and Gradle 4.
My problem is that I do not understand why the @CompileStatic breaks the execution. I looked in Gradle source code and methods are only deprecated, not removed yet.
Can someone shed a bit of light on this please?
I can provide a small test case if need be.
Regards.