Small changes to Gradle build scripts
Kevin Rushforth
kevin.rushforth at oracle.com
Fri Jan 20 23:29:58 UTC 2023
It does look cleaner, and I guess every little bit helps. If you want to
file a cleanup enhancement, we can take a look, but it won't be a very
high priority.
-- Kevin
On 1/20/2023 6:51 AM, Scott Palmer wrote:
> Are small simplifying changes to the gradle scripts welcome?
>
> E.g. instead of:
> def inStream = new java.io.BufferedReader(new
> java.io.InputStreamReader(new java.lang.ProcessBuilder(JAVA,
> "-fullversion").start().getErrorStream()));
> try {
> String v = inStream.readLine().trim();
> if (v != null) {
> int ib = v.indexOf("full version \"");
> if (ib != -1) {
> String str = v.substring(ib);
> String ver = str.substring(str.indexOf("\"") + 1, str.size() - 1);
> defineProperty("jdkRuntimeVersion", ver)
> def jdkVersionInfo = parseJavaVersion(ver)
> defineProperty("jdkVersion", jdkVersionInfo[0])
> defineProperty("jdkBuildNumber", jdkVersionInfo[1])
> // Define global properties based on the version of Java
> // For example, we could define a "jdk18OrLater" property as
> // follows that could then be used to implement conditional build
> // logic based on whether we were running on JDK 18 or later,
> // should the need arise.
> // def status = compareJdkVersion(jdkVersion, "18")
> // ext.jdk18OrLater = (status >= 0)
> }
> }
> } finally {
> inStream.close();
> }
>
> this:
> def verMatch = [JAVA, "-fullversion"].execute().err.text =~ /full
> version "([^"]+)/
> if (verMatch.find()) {
> String ver = verMatch.group(1);
> defineProperty("jdkRuntimeVersion", ver)
> def jdkVersionInfo = parseJavaVersion(ver)
> defineProperty("jdkVersion", jdkVersionInfo[0])
> defineProperty("jdkBuildNumber", jdkVersionInfo[1])
> // Define global properties based on the version of Java
> // For example, we could define a "jdk18OrLater" property as
> // follows that could then be used to implement conditional build
> // logic based on whether we were running on JDK 18 or later,
> // should the need arise.
> // def status = compareJdkVersion(jdkVersion, "18")
> // ext.jdk18OrLater = (status >= 0)
> }
>
> or instead of:
> ext.HAS_JAVAFX_MODULES = false;
> def inStream2 = new java.io.BufferedReader(new
> java.io.InputStreamReader(new java.lang.ProcessBuilder(JAVA,
> "--list-modules").start().getInputStream()));
> try {
> String v;
> while ((v = inStream2.readLine()) != null) {
> v = v.trim();
> if (v.startsWith("javafx.base")) ext.HAS_JAVAFX_MODULES = true;
> }
> } finally {
> inStream2.close();
> }
>
> this:
> ext.HAS_JAVAFX_MODULES = [JAVA,
> '--list-modules'].execute().text.contains('javafx.base')
>
> ... much simpler and seems to work just as well.
>
> They don't do much more than improve readability and reduce the line
> count though, so I'm not sure if anyone cares.
>
> Scott
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/openjfx-dev/attachments/20230120/c4a59898/attachment-0001.htm>
More information about the openjfx-dev
mailing list