Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure Gradle build for use with newer JDKs #24474

Closed
sbrannen opened this issue Feb 3, 2020 · 7 comments
Closed

Configure Gradle build for use with newer JDKs #24474

sbrannen opened this issue Feb 3, 2020 · 7 comments
Assignees
Labels
type: task A general task
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Feb 3, 2020

Overview

In order to test the Spring Framework against newer versions of the JDK (e.g., early access builds for JDK 14, 15, etc.), we should introduce support in our Gradle build that allows us to select an alternative JDK (JAVA_HOME) to use when executing and/or compiling tests.

Proposal

Introduce system properties that can control whether an alternative Java installation is to be used for the current build.

Investigate options available on the CI server (e.g., existing environment variables that point to JDK installations).

Notes

The Bamboo CI server has JDK 14ea installed in /opt/jdk-14. Moreover, installed JDKs available include /opt/jdk-[7-14].

Related Issues

@sbrannen sbrannen added the type: task A general task label Feb 3, 2020
@sbrannen sbrannen added this to the 5.2.4 milestone Feb 3, 2020
@sbrannen sbrannen self-assigned this Feb 3, 2020
@sbrannen
Copy link
Member Author

sbrannen commented Feb 5, 2020

Current work on this issue can be seen in the following feature branch: https://github.com/sbrannen/spring-framework/commits/issues/gh-24474-alternate-jdk-versions

@sbrannen
Copy link
Member Author

sbrannen commented Feb 6, 2020

Also related to #24215 for proper Groovy support.

sbrannen added a commit to sbrannen/spring-framework that referenced this issue Feb 6, 2020
This commit adds support for the following two JVM system properties
that control the Gradle build for alternative JDKs (i.e., a JDK other
than the one used to launch the Gradle process).

- customJavaHome: absolute path to the alternate JDK installation to
  use to compile Java code and execute tests. Setting this system
  property causes Groovy 3.0 RC3 to be used instead of 2.5.x. This
  system property is also used in spring-oxm.gradle to determine
  whether JiBX is supported.

- customJavaSourceVersion: Java version supplied to the `--release`
  command line flag to control the Java source and target compatibility
  version. Supported versions include 9 or higher. Do not set this
  system property if Java 8 should be used.

Examples:

./gradlew -DcustomJavaHome=/opt/java/jdk-14 test

./gradlew --no-build-cache -DcustomJavaHome=/opt/java/jdk-14 test

./gradlew -DcustomJavaHome=/opt/java/jdk-14 -DcustomJavaSourceVersion=14 test

See spring-projectsgh-24474
sbrannen added a commit that referenced this issue Feb 6, 2020
This commit adds support for the following two JVM system properties
that control the Gradle build for alternative JDKs (i.e., a JDK other
than the one used to launch the Gradle process).

- customJavaHome: absolute path to the alternate JDK installation to
  use to compile Java code and execute tests. Setting this system
  property causes Groovy 3.0 RC3 to be used instead of 2.5.x. This
  system property is also used in spring-oxm.gradle to determine
  whether JiBX is supported.

- customJavaSourceVersion: Java version supplied to the `--release`
  command line flag to control the Java source and target compatibility
  version. Supported versions include 9 or higher. Do not set this
  system property if Java 8 should be used.

Examples:

./gradlew -DcustomJavaHome=/opt/java/jdk-14 test

./gradlew --no-build-cache -DcustomJavaHome=/opt/java/jdk-14 test

./gradlew -DcustomJavaHome=/opt/java/jdk-14 -DcustomJavaSourceVersion=14 test

See gh-24474
sbrannen added a commit that referenced this issue Feb 6, 2020
@sbrannen
Copy link
Member Author

sbrannen commented Feb 6, 2020

Update:

Support was added to the build in 8f02e10.

A dedicated build plan for JDK 14 will follow on the CI server.

@sbrannen
Copy link
Member Author

sbrannen commented Feb 6, 2020

Since the 1st build of the JDK 14 build plan passed on the CI server (https://build.spring.io/browse/SPR-JDK14-1), I am closing this issue.

@sbrannen sbrannen closed this as completed Feb 6, 2020
sbrannen added a commit that referenced this issue Feb 7, 2020
Prior to this commit, the "-Werror" was removed as a command-line
argument in order not to fail the build for missing classpath elements.

This commit reinstates "-Werror" and removes "-Xlink:path" in order to
explicitly ignore warnings for missing classpath elements when executing
the build with a custom JAVA_HOME.

See gh-24474
sbrannen added a commit that referenced this issue Feb 12, 2020
Setting `options.fork = true` causes the classpath in the forked
compiler process to include Class-Path entries from MANIFEST.MF files
in JARs in the classpath, which results in warnings about missing
classpath entries.

This commit removes the `options.fork = true` declaration and further
simplifies the script.

See gh-24474
@sbrannen
Copy link
Member Author

The aforementioned commit adds support for the following two JVM system properties that control the Gradle build for alternative JDKs (i.e., a JDK other than the one used to launch the Gradle process).

  • customJavaHome: absolute path to the alternate JDK installation to use to compile Java code and execute tests. Setting this system property causes Groovy 3.0 to be used instead of 2.5.x. This system property is also used in spring-oxm.gradle to determine whether JiBX is supported.

  • customJavaSourceVersion: Java version supplied to the --release command line flag to control the Java source and target compatibility version. Supported versions include 9 or higher. Do not set this system property if Java 8 should be used.

Examples:

./gradlew -DcustomJavaHome=/opt/java/jdk-14 test

./gradlew --no-build-cache -DcustomJavaHome=/opt/java/jdk-14 test

./gradlew -DcustomJavaHome=/opt/java/jdk-14 -DcustomJavaSourceVersion=14 test

@jhoeller
Copy link
Contributor

@sbrannen I'll switch to a single canonical version of Groovy again for Spring Framework 5.2.5 since the recently released Groovy 2.5.10 seems to have good enough JDK 14 support for the time being. See #24719

@sbrannen
Copy link
Member Author

OK. Thanks for the heads-up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants