From ae520084632ac70a5371bf8e453aa70521ebae51 Mon Sep 17 00:00:00 2001 From: Andriy Redko Date: Fri, 4 Mar 2022 17:44:52 -0500 Subject: [PATCH] Fixing the --release flag usage for javac (#2343) (#2352) * Fixing the --release flag usage for javac (#2343) * Fixing the --release flag usage for javac Signed-off-by: Andriy Redko * Fixing the --html5 flag usage for javadoc Signed-off-by: Andriy Redko * Fix java-version-checker source/target compatibility settings (#2354) Signed-off-by: Andriy Redko --- .../java/org/opensearch/gradle/OpenSearchJavaPlugin.java | 9 +++++++-- distribution/tools/java-version-checker/build.gradle | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java index e63a281c3e1..c701c47f9e6 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java @@ -173,7 +173,10 @@ public class OpenSearchJavaPlugin implements Plugin { // workaround for https://github.com/gradle/gradle/issues/14141 compileTask.getConventionMapping().map("sourceCompatibility", () -> java.getSourceCompatibility().toString()); compileTask.getConventionMapping().map("targetCompatibility", () -> java.getTargetCompatibility().toString()); - compileOptions.getRelease().set(releaseVersionProviderFromCompileTask(project, compileTask)); + // The '--release is available from JDK-9 and above + if (BuildParams.getRuntimeJavaVersion().compareTo(JavaVersion.VERSION_1_8) > 0) { + compileOptions.getRelease().set(releaseVersionProviderFromCompileTask(project, compileTask)); + } }); // also apply release flag to groovy, which is used in build-tools project.getTasks().withType(GroovyCompile.class).configureEach(compileTask -> { @@ -267,7 +270,9 @@ public class OpenSearchJavaPlugin implements Plugin { * that the default will change to html5 in the future. */ CoreJavadocOptions javadocOptions = (CoreJavadocOptions) javadoc.getOptions(); - javadocOptions.addBooleanOption("html5", true); + if (BuildParams.getRuntimeJavaVersion().compareTo(JavaVersion.VERSION_1_8) > 0) { + javadocOptions.addBooleanOption("html5", true); + } }); TaskProvider javadoc = project.getTasks().withType(Javadoc.class).named("javadoc"); diff --git a/distribution/tools/java-version-checker/build.gradle b/distribution/tools/java-version-checker/build.gradle index 1990c2b35c1..d3b1422de47 100644 --- a/distribution/tools/java-version-checker/build.gradle +++ b/distribution/tools/java-version-checker/build.gradle @@ -11,7 +11,8 @@ apply plugin: 'opensearch.build' -targetCompatibility = JavaVersion.VERSION_1_7 +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 // targetting very old java versions enables a warning by default on newer JDK: disable it. compileJava.options.compilerArgs += '-Xlint:-options'