gradle-java-cross-compile-plugin icon indicating copy to clipboard operation
gradle-java-cross-compile-plugin copied to clipboard

Major design and functionality flaws

Open Vampire opened this issue 7 years ago • 1 comments
trafficstars

From a quick look at your code I'd say your plugin has at least three major flaws:

  • You check the targetCompatibility of the convention object, but that is just the default for the JavaCompileand similar tasks. Instead you should check the targetCompatibility of 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.

Vampire avatar Mar 21 '18 22:03 Vampire

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.

Vampire avatar Jul 16 '18 10:07 Vampire