RFR: 8344906: Simplify Java version parsing in the build file
Ambarish Rapte
arapte at openjdk.org
Wed Nov 27 01:44:46 UTC 2024
On Sat, 23 Nov 2024 09:22:36 GMT, Nir Lisker <nlisker at openjdk.org> wrote:
> Replaces the manual versions handling with [Version](https://docs.oracle.com/en/java/javase/23/docs/api/java.base/java/lang/Runtime.Version.html).
>
> Changes:
> * Removed the methods `parseJavaVersion(String)`, `parseJdkVersion(String)` and `compareJdkVersion(String, String)`, and replaced them with `Version.parse` and `Version.compareTo` methods.
> * Removed the build properties of the Java version on which the Gradle build runs because they are only used for logging. Replaced with logging them directly. Note that Gradle logs by itself the info of the runtime it uses, so there's no need to logs these manually.
> * Simplified the build JDK version by working directly with `Version` instead of a `String`. This allows to store less build properties. Also used try-with-resources to close the stream. Note that the whole build JDK manual invocation hack should be replaced with the Java Toolchain.
> * Simplified the `verifyJava` task, which could also be replaced with built-in Gradle tools.
LGTM, with a minor correction (shall re-approve, when changed).
It fails as expected if we use JDK older than `jfx.build.jdk.version`
Execution failed for task ':verifyJava'.
> FAIL: java version mismatch: JDK version (21.0.2+13-58) < minimum version (22+36)
logs are as expected:
java.runtime.version: 23+37-2369
java version: 23
java build number: 37
jdk.runtime.version: 23+37-2369
jdk version: 23
jdk build 37
build.gradle line 1488:
> 1486: logger.quiet("jdk.runtime.version: " + jdkVersionInfo)
> 1487: logger.quiet("jdk version: " + jdkVersionInfo.feature())
> 1488: logger.quiet("jdk build " + javaVersionInfo.build().orElse(0))
minor: missing **:** after _jdk build_
-------------
Marked as reviewed by arapte (Reviewer).
PR Review: https://git.openjdk.org/jfx/pull/1647#pullrequestreview-2463372382
PR Review Comment: https://git.openjdk.org/jfx/pull/1647#discussion_r1859614813
More information about the openjfx-dev
mailing list