Remove source- and targetCompatiblity options and use javaCompile.options.release instead
MODIFY
CHANGELOG.adoc
CHANGELOG.adoc
@@ -23,6 +23,10 @@ Bug Fixes::
Deprecated Attributes.setTableOfContents2().
Added new constants Placement.PREAMBLE and Placement.MACRO as parameters for Attributes.setTableOfConstants(). (@abelsromero) (#1037)
+Build Improvement::
+
+* Use JavaCompile options.release instead of sourceCompatibility and targetCompatibility to target Java 8 (#1042)
+
== 2.5.1 (2021-05-04)
Improvement::

MODIFY
build.gradle
build.gradle
@@ -103,14 +103,10 @@ subprojects {
status = _status
- // NOTE sourceCompatibility & targetCompatibility are set in gradle.properties to meet requirements of Gradle
- // Must redefine here to work around a bug in the Eclipse plugin
- sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
plugins.withType(JavaPlugin) {
project.tasks.withType(JavaCompile) { task ->
- task.sourceCompatibility = project.sourceCompatibility
- task.targetCompatibility = project.targetCompatibility
+ task.options.release = 8
if (project.hasProperty("showDeprecation")) {
options.compilerArgs << "-Xlint:deprecation"
}
@@ -119,8 +115,7 @@ subprojects {
}
}
project.tasks.withType(GroovyCompile) { task ->
- task.sourceCompatibility = project.sourceCompatibility
- task.targetCompatibility = project.targetCompatibility
+ task.options.release = 8
}
}
@@ -204,14 +199,12 @@ configure(subprojects.findAll { !it.isDistribution() }) {
ruby.gems()
}
- if (JavaVersion.current().isJava8Compatible()) {
javadoc {
// Oracle JDK8 likes to fail the build over spoiled HTML
options.addStringOption('Xdoclint:none', '-quiet')
options.source('8')
}
}
-}
configure(subprojects.findAll { !it.name.endsWith('-distribution') && ! it.name.endsWith('-documentation')}) {

MODIFY
gradle.properties
gradle.properties
version=2.5.2-SNAPSHOT
-sourceCompatibility=1.8
-targetCompatibility=1.8
org.gradle.jvmargs=-XX:MaxMetaspaceSize=512m

Remove source- and targetCompatiblity options and use javaCompile.options.release instead