gradle-java-cross-compile-plugin
gradle-java-cross-compile-plugin copied to clipboard
Major design and functionality flaws
From a quick look at your code I'd say your plugin has at least three major flaws:
-
You check the
targetCompatibilityof the convention object, but that is just the default for theJavaCompileand similar tasks. Instead you should check thetargetCompatibilityof the respective tasks which can be different from the convention object. Also that way you could easily have a project with a Java 9 compiled source set and a Java 8 compiled source set, e. g. to build a multi-release JAR. -
You should also support setting the boot path for the JavaDoc type tasks.
-
You should not apply the Java base plugin, but either react to it being applied with something like
project.plugins.withId(), or as you shouldn't use the convention anyway, even not that, but just react to tasks with the respective types and conditions, as you can also apply them without the Java base plugin.
And actually considering building on Java 9+, the bootclasspath does not need to be set at all anymore, but just the --release switch, so something like
tasks.withType(JavaCompile) {
if (JavaVersion.current().java9Compatible) {
afterEvaluate {
options.compilerArgs << '--release' << platform.targetCompatibility.majorVersion
}
} else {
// set the bootclasspath here
}
}
would maybe make sense.