-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Require JDK 9 for compilation #28071
Conversation
This commit modifies the build to require JDK 9 for compilation. Henceforth, we will compile with a JDK 9 compiler targeting JDK 8 as the class file format. Optionally, JAVA_8_HOME can be set as the runtime JDK used for running tests. To enable this change, we separate the meaning of the compiler Java home versus the runtime Java home. If the runtime Java home is not set (via JAVA_8_HOME) then we fallback to using JAVA_HOME as the runtime Java home. This enables: - developers only have to set one Java home (JAVA_HOME) - developers can set an optional Java home (JAVA_8_HOME) to test on the minimum supported runtime - we can test compiling with JDK 9 running on JDK 8 and compiling with JDK 9 running on JDK 9 in CI
I tested this PR with Eclipse IDE and can confirm that it causes no problems for my dev environment |
7aabf0a
to
fab460e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left one suggestion. I've not tested the change but looks good to me.
final String maybeJavaHome | ||
if (java8Home == null) { | ||
// if JAVA_8_HOME is not set fallback to JAVA_HOME | ||
maybeJavaHome = System.getenv('JAVA_HOME') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe simpler to let the method findCompilerJavaHome
stay named findJavaHome
and just call maybeJavaHome = findJavaHome()
here? This means we don't have to duplicate all the logic around idea.active
etc. Yet another alternative would be to pass a fallback parameter to findRuntimeJavaHome
.
* master: Set the elasticsearch-nio codebase for tests (elastic#28067) Bump compat version for local depdendent test to 6.2.0 Pass `java.locale.providers=COMPAT` to Java 9 onwards (elastic#28080) Allow shrinking of indices from a previous major (elastic#28076) Remove deprecated exceptions (elastic#28059) Add Writeable.Reader support to TransportResponseHandler (elastic#28010) Plugins: Add plugin extension capabilities (elastic#27881)
* master: test: replaced try-catch statements with expectThrows(...) Add getWarmer and getTranslog method to NodeIndicesStats (elastic#28092) fix doc mistake Added ASN support for Ingest GeoIP plugin. Fix global aggregation that requires breadth first and scores (elastic#27942) Introduce Gradle wrapper Ignore GIT_COMMIT when calculating commit hash Re-enable bwc tests after elastic#27881 was backported
@@ -182,6 +180,34 @@ class BuildPlugin implements Plugin<Project> { | |||
return javaHome | |||
} | |||
|
|||
private static String findRuntimeJavaHome(Project project) { | |||
String java8Home = System.getenv('JAVA_8_HOME') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should use a more explicit name here, like ES_TEST_JAVA_HOME for a couple reasons:
- I personally have env vars for each version of java, so I can quickly switch to that java version with an alias. I always have this env set, so it would mean for me I would always be testing against java 8.
- This doesn't have to be java 8 specific. The same feature of our build can be used to test against a different jvm like azul or ibm, while still building with the official java 9 jdk we use for releases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed this with @rjernst and after some consideration I agree. We agreed to name the variable RUNTIME_JAVA_HOME
though.
* master: Remove Gradle cheatsheet Fix reproduction info to point to Gradle wrapper Update platforms tests to use Gradle wrapper Update testing docs to reflect Gradle wrapper Painless: Modify Loader to Load Classes Directly from Definition (elastic#28088) Update contributing docs to use the Gradle wrapper Create nio-transport plugin for NioTransport (elastic#27949)
* master: Use Gradle wrapper when building BWC Painless: Add a simple cache for whitelist methods and fields. (elastic#28142) Fix upgrading indices which use a custom similarity plugin. (elastic#26985) Fix Licenses values for CDDL and Custom URL (elastic#27999) Cleanup TcpChannelFactory and remove classes (elastic#28102) Fix expected plugins test for transport-nio [Docs] Fix Date Math example descriptions (elastic#28125) Fail rollover if duplicated alias found in template (elastic#28110) Avoid concurrent snapshot finalizations when deleting an INIT snapshot (elastic#28078) Deprecate `isShardsAcked()` in favour of `isShardsAcknowledged()` (elastic#27819) [TEST] Wait for replicas to be allocated before shrinking Use the underlying connection version for CCS connections (elastic#28093) test: do not use asn fields Test: Add assumeFalse for test that cannot pass on windows Clarify reproduce info on Windows Remove out-of-date projectile file
* master: Fix Gradle wrapper usage on Windows when building BWC (elastic#28146) [Docs] Fix some typos in comments (elastic#28098)
* master: Set watermarks in single-node test cases Add the ability to bundle multiple plugins into a meta plugin (elastic#28022) Declare empty package dirs as output dirs Consistent updates of IndexShardSnapshotStatus (elastic#28130)
* master: (30 commits) Fix lock accounting in releasable lock Add ability to associate an ID with tasks (elastic#27764) [DOCS] Removed differencies between text and code (elastic#27993) text fixes (elastic#28136) Update getting-started.asciidoc (elastic#28145) [Docs] Spelling fix in painless-getting-started.asciidoc (elastic#28187) Fixed the cat.health REST test to accept 4ms, not just 4.0ms (elastic#28186) Do not keep 5.x commits once having 6.x commits (elastic#28188) Rename core module to server (elastic#28180) upgraded jna from 4.4.0-1 to 4.5.1 (elastic#28183) [TEST] Do not call RandomizedTest.scaledRandomIntBetween from multiple threads Primary send safe commit in file-based recovery (elastic#28038) [Docs] Correct response json in rank-eval.asciidoc Add scroll parameter to _reindex API (elastic#28041) Include all sentences smaller than fragment_size in the unified highlighter (elastic#28132) Modifies the JavaAPI docs related to AggregationBuilder [Docs] Improvements in script-fields.asciidoc (elastic#28174) [Docs] Remove Kerberos/SPNEGO Shield plugin (elastic#28019) Ignore null value for range field (elastic#27845) (elastic#28116) Fix environment variable substitutions in list setting (elastic#28106) ...
* master: TEST: init unassigned gcp in testAcquireIndexCommit Replica start peer recovery with safe commit (elastic#28181) Truncate tlog cli should assign global checkpoint (elastic#28192)
* master: (21 commits) [GEO] Add WKT Support to GeoBoundingBoxQueryBuilder Painless: Add whitelist extensions (elastic#28161) Fix daitch_mokotoff phonetic filter to use the dedicated Lucene filter (elastic#28225) Avoid doing redundant work when checking for self references. (elastic#26927) Fix casts in HotThreads. (elastic#27578) Ignore the `-snapshot` suffix when comparing the Lucene version in the build and the docs. (elastic#27927) Allow update of `eager_global_ordinals` on `_parent`. (elastic#28014) Fix NPE on composite aggregation with sub-aggregations that need scores (elastic#28129) `MockTcpTransport` to connect asynchronously (elastic#28203) Fix synonym phrase query expansion for cross_fields parsing (elastic#28045) Introduce elasticsearch-core jar (elastic#28191) elastic#28218: Update the Lucene version for 6.2.0 after backport upgrade to lucene 7.2.1 (elastic#28218) [Docs] Fix an error in painless-types.asciidoc (elastic#28221) Adds metadata to rewritten aggregations (elastic#28185) Update version of TaskInfo header serialization after backport TEST: Tightens file-based condition in peer-recovery Correct backport replica rollback to 6.2 (elastic#28181) Backport replica rollback to 6.2 (elastic#28181) Rename deleteLocalTranslog to createNewTranslog ...
javaHome = Jvm.current().javaHome | ||
} else { | ||
throw new GradleException('JAVA_HOME must be set to build Elasticsearch') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this exception changed to an assertion? Is it moved somewhere else I'm missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am glad that you caught this. This was inadvertent, it arose in a refactoring I did in 95475f9 which refactored two basically identical methods from an earlier version of this pull request (findCompilerJavaHome
and findRuntimeJavaHome
) into one (findJavaHome
). Before the refactoring, the second method did not need such a line because by the time it had executed the first one would have already thrown that exception (hence the assert false
). When I refactored, I must have based by work on findRuntimeJavaHome
inadvertently losing this exception. I have pushed: bcee920.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
assert minimumJava == JavaVersion.VERSION_1_8 | ||
options.compilerArgs << '--release' << '8' | ||
} | ||
options.compilerArgs << '--release' << project.targetCompatibility.majorVersion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment to this line linking the relevant gradle issue for adding builtin support for this: gradle/gradle#2510
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed 9434717.
* master: [Docs] Fix base directory to include for put_mapping.asciidoc Open engine should keep only starting commit (elastic#28228) [Docs] Fix Java Api index administration usage (elastic#28133) Fix eclipse build. (elastic#28236) Never return null from Strings.tokenizeToStringArray (elastic#28224) Fallback to TransportMasterNodeAction for cluster health retries (elastic#28195) [Docs] Changes to ingest.asciidoc (elastic#28212) TEST: Update logging for testAckedIndexing
* master: Revert "[Docs] Fix Java Api index administration usage (elastic#28133)" Revert "[Docs] Fix base directory to include for put_mapping.asciidoc" Added multi get api to the high level rest client. [Docs] Clarify numeric datatype ranges (elastic#28240)
This commit modifies the build to require JDK 9 for compilation. Henceforth, we will compile with a JDK 9 compiler targeting JDK 8 as the class file format. Optionally, RUNTIME_JAVA_HOME can be set as the runtime JDK used for running tests. To enable this change, we separate the meaning of the compiler Java home versus the runtime Java home. If the runtime Java home is not set (via RUNTIME_JAVA_HOME) then we fallback to using JAVA_HOME as the runtime Java home. This enables: - developers only have to set one Java home (JAVA_HOME) - developers can set an optional Java home (RUNTIME_JAVA_HOME) to test on the minimum supported runtime - we can test compiling with JDK 9 running on JDK 8 and compiling with JDK 9 running on JDK 9 in CI Relates #28071
* master: (35 commits) Move the multi-get response tests to server Require JDK 9 for compilation (elastic#28071) Revert "[Docs] Fix Java Api index administration usage (elastic#28133)" Revert "[Docs] Fix base directory to include for put_mapping.asciidoc" Added multi get api to the high level rest client. [Docs] Clarify numeric datatype ranges (elastic#28240) [Docs] Fix base directory to include for put_mapping.asciidoc Open engine should keep only starting commit (elastic#28228) [Docs] Fix Java Api index administration usage (elastic#28133) Fix eclipse build. (elastic#28236) Never return null from Strings.tokenizeToStringArray (elastic#28224) Fallback to TransportMasterNodeAction for cluster health retries (elastic#28195) [Docs] Changes to ingest.asciidoc (elastic#28212) TEST: Update logging for testAckedIndexing [GEO] Add WKT Support to GeoBoundingBoxQueryBuilder Painless: Add whitelist extensions (elastic#28161) Fix daitch_mokotoff phonetic filter to use the dedicated Lucene filter (elastic#28225) Avoid doing redundant work when checking for self references. (elastic#26927) Fix casts in HotThreads. (elastic#27578) Ignore the `-snapshot` suffix when comparing the Lucene version in the build and the docs. (elastic#27927) ...
* master: Fix third-party audit tasks on JDK 8 Remove duplicated javadoc `fieldType` param Handle 5.6.6 and 6.1.2 release Introduce multi-release JAR Move the multi-get response tests to server Require JDK 9 for compilation (#28071) Revert "[Docs] Fix Java Api index administration usage (#28133)" Revert "[Docs] Fix base directory to include for put_mapping.asciidoc" Added multi get api to the high level rest client. [Docs] Clarify numeric datatype ranges (#28240) [Docs] Fix base directory to include for put_mapping.asciidoc Open engine should keep only starting commit (#28228)
* 6.x: Fix third-party audit tasks on JDK 8 Remove duplicated javadoc `fieldType` param Handle 5.6.6 and 6.1.2 release Introduce multi-release JAR Move the multi-get response tests to server Require JDK 9 for compilation (#28071) Revert "[Docs] Fix Java Api index administration usage (#28133)" Revert "[Docs] Fix base directory to include for put_mapping.asciidoc" Added multi get api to the high level rest client. Open engine should keep only starting commit (#28228) [Docs] Clarify numeric datatype ranges (#28240) Add migration guide for 6.1 [Docs] Fix base directory to include for put_mapping.asciidoc [Docs] Fix Java Api index administration usage (#28133) Add 6.1.2 release notes
This commit modifies the build to require JDK 9 for compilation. Henceforth, we will compile with a JDK 9 compiler targeting JDK 8 as the class file format. Optionally, RUNTIME_JAVA_HOME can be set as the runtime JDK used for running tests. To enable this change, we separate the meaning of the compiler Java home versus the runtime Java home. If the runtime Java home is not set (via RUNTIME_JAVA_HOME) then we fallback to using JAVA_HOME as the runtime Java home. This enables:
minimum supported runtime
Relates #28051