Skip to content

Commit 1c7a2b8

Browse files
committed
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]>
1 parent 729bc43 commit 1c7a2b8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
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");

0 commit comments

Comments
 (0)