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 <andriy.redko@aiven.io>

* Fixing the --html5 flag usage for javadoc

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

* Fix java-version-checker source/target compatibility settings (#2354)

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
This commit is contained in:
Andriy Redko 2022-03-04 17:44:52 -05:00 committed by GitHub
parent 0cc2c9be6a
commit ae52008463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -173,7 +173,10 @@ public class OpenSearchJavaPlugin implements Plugin<Project> {
// 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<Project> {
* 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> javadoc = project.getTasks().withType(Javadoc.class).named("javadoc");

View File

@ -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'