Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit ae52008

Browse files
authored
Fixing the --release flag usage for javac (opensearch-project#2343) (opensearch-project#2352)
* Fixing the --release flag usage for javac (opensearch-project#2343) * Fixing the --release flag usage for javac Signed-off-by: Andriy Redko <[email protected]> * Fixing the --html5 flag usage for javadoc Signed-off-by: Andriy Redko <[email protected]> * Fix java-version-checker source/target compatibility settings (opensearch-project#2354) Signed-off-by: Andriy Redko <[email protected]>
1 parent 0cc2c9b commit ae52008

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

buildSrc/src/main/java/org/opensearch/gradle/OpenSearchJavaPlugin.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ public static void configureCompile(Project project) {
173173
// workaround for https://github.com/gradle/gradle/issues/14141
174174
compileTask.getConventionMapping().map("sourceCompatibility", () -> java.getSourceCompatibility().toString());
175175
compileTask.getConventionMapping().map("targetCompatibility", () -> java.getTargetCompatibility().toString());
176-
compileOptions.getRelease().set(releaseVersionProviderFromCompileTask(project, compileTask));
176+
// The '--release is available from JDK-9 and above
177+
if (BuildParams.getRuntimeJavaVersion().compareTo(JavaVersion.VERSION_1_8) > 0) {
178+
compileOptions.getRelease().set(releaseVersionProviderFromCompileTask(project, compileTask));
179+
}
177180
});
178181
// also apply release flag to groovy, which is used in build-tools
179182
project.getTasks().withType(GroovyCompile.class).configureEach(compileTask -> {
@@ -267,7 +270,9 @@ private static void configureJavadoc(Project project) {
267270
* that the default will change to html5 in the future.
268271
*/
269272
CoreJavadocOptions javadocOptions = (CoreJavadocOptions) javadoc.getOptions();
270-
javadocOptions.addBooleanOption("html5", true);
273+
if (BuildParams.getRuntimeJavaVersion().compareTo(JavaVersion.VERSION_1_8) > 0) {
274+
javadocOptions.addBooleanOption("html5", true);
275+
}
271276
});
272277

273278
TaskProvider<Javadoc> javadoc = project.getTasks().withType(Javadoc.class).named("javadoc");

distribution/tools/java-version-checker/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
apply plugin: 'opensearch.build'
1313

14-
targetCompatibility = JavaVersion.VERSION_1_7
14+
sourceCompatibility = JavaVersion.VERSION_1_8
15+
targetCompatibility = JavaVersion.VERSION_1_8
1516
// targetting very old java versions enables a warning by default on newer JDK: disable it.
1617
compileJava.options.compilerArgs += '-Xlint:-options'
1718

0 commit comments

Comments
 (0)