From ceff71fa9832051b6aa9b633271e6005d9b655a6 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Mon, 23 May 2016 12:28:54 -0700 Subject: [PATCH] Build: Use -release with java 9 instead of -source/-target This uses the new -release flag for javac which does not require setting the bootclasspath as -source/-target did. --- build.gradle | 8 ++++++++ .../org/elasticsearch/gradle/BuildPlugin.groovy | 13 ++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index c843069f43ee4..bf4b5a3b415ef 100644 --- a/build.gradle +++ b/build.gradle @@ -144,6 +144,14 @@ subprojects { // see https://discuss.gradle.org/t/add-custom-javadoc-option-that-does-not-take-an-argument/5959 javadoc.options.encoding='UTF8' javadoc.options.addStringOption('Xdoclint:all,-missing', '-quiet') + /* + TODO: building javadocs with java 9 b118 is currently broken with weird errors, so + for now this is commented out...try again with the next ea build... + javadoc.executable = new File(project.javaHome, 'bin/javadoc') + if (project.javaVersion == JavaVersion.VERSION_1_9) { + // TODO: remove this hack! gradle should be passing this... + javadoc.options.addStringOption('source', '8') + }*/ } } diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 455f16d123ae6..168ceca1d2383 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -143,7 +143,7 @@ class BuildPlugin implements Plugin { } project.rootProject.ext.javaHome = javaHome - project.rootProject.ext.javaVersion = javaVersion + project.rootProject.ext.javaVersion = javaVersionEnum project.rootProject.ext.buildChecksDone = true } project.targetCompatibility = minimumJava @@ -387,10 +387,13 @@ class BuildPlugin implements Plugin { options.encoding = 'UTF-8' //options.incremental = true - // gradle ignores target/source compatibility when it is "unnecessary", but since to compile with - // java 9, gradle is running in java 8, it incorrectly thinks it is unnecessary - assert minimumJava == JavaVersion.VERSION_1_8 - options.compilerArgs << '-target' << '1.8' << '-source' << '1.8' + if (project.javaVersion == JavaVersion.VERSION_1_9) { + // hack until gradle supports java 9's new "-release" arg + assert minimumJava == JavaVersion.VERSION_1_8 + options.compilerArgs << '-release' << '8' + project.sourceCompatibility = null + project.targetCompatibility = null + } } } }