DEV Community

Clayton Walker
Clayton Walker

Posted on • Edited on

3 3

Stop using sourceCompatibility and targetCompatibility

And start using --release. As of JEP-247 released in java 9, the flag will allow you to compile for older releases of java without worrying about the dreaded NoSuchMethodError.

Stop talking and show me the code!

Gradle

tasks.withType(JavaCompile) {
    options.release = 8
}
Enter fullscreen mode Exit fullscreen mode

Gradle (kts)

tasks.withType<JavaCompile> {
    options.release.set(8)
}
Enter fullscreen mode Exit fullscreen mode

Maven (xml)

<configuration>
    <release>8</release>
</configuration>
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay