Skip to content

Commit 8deadfb

Browse files
authored
Bump the minimum Java version to Java 11 (#40754)
With the 8.0.0 release of Elasticsearch we will bump the minimum required Java to Java 11. This commit puts this into effect on the master branch.
1 parent e10f779 commit 8deadfb

File tree

32 files changed

+129
-568
lines changed

32 files changed

+129
-568
lines changed

.ci/java-versions.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
# are 'java' or 'openjdk' followed by the major release number.
66

77
ES_BUILD_JAVA=openjdk12
8-
ES_RUNTIME_JAVA=java8
8+
ES_RUNTIME_JAVA=java11
99
GRADLE_TASK=build
1010

.ci/matrix-runtime-javas.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@
66
# or 'openjdk' followed by the major release number.
77

88
ES_RUNTIME_JAVA:
9-
- java8
10-
- java8fips
119
- java11
1210
- java12
1311
- openjdk12
14-
- zulu8
1512
- zulu11
1613
- zulu12

Vagrantfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,10 @@ def linux_common(config,
246246
touch /is_vagrant_vm # for consistency between linux and windows
247247
SHELL
248248

249+
config.vm.provision 'jdk-11', type: 'shell', inline: <<-SHELL
250+
curl -sSL https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_linux-x64_bin.tar.gz | tar xz -C /opt/
251+
SHELL
252+
249253
# This prevents leftovers from previous tests using the
250254
# same VM from messing up the current test
251255
config.vm.provision 'clean es installs in tmp', run: 'always', type: 'shell', inline: <<-SHELL
@@ -342,7 +346,7 @@ def sh_install_deps(config,
342346
}
343347
cat \<\<JAVA > /etc/profile.d/java_home.sh
344348
if [ -z "\\\$JAVA_HOME" ]; then
345-
export JAVA_HOME=$(dirname $(dirname $(readlink -f $(which java))))
349+
export JAVA_HOME=/opt/jdk-11.0.2
346350
fi
347351
export SYSTEM_JAVA_HOME=\\\$JAVA_HOME
348352
unset JAVA_HOME

buildSrc/build.gradle

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ dependencies {
123123
compile 'com.perforce:p4java:2012.3.551082' // THIS IS SUPPOSED TO BE OPTIONAL IN THE FUTURE....
124124
compile 'org.apache.rat:apache-rat:0.11'
125125
compile "org.elasticsearch:jna:4.5.1"
126-
compile 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
126+
compile 'com.github.jengelman.gradle.plugins:shadow:4.0.3'
127127
compile 'de.thetaphi:forbiddenapis:2.6'
128128
compile 'com.avast.gradle:gradle-docker-compose-plugin:0.8.12'
129129
testCompile "junit:junit:${props.getProperty('junit')}"
@@ -199,14 +199,6 @@ if (project != rootProject) {
199199
into localDownloads
200200
}
201201

202-
unitTest {
203-
// The test task is configured to runtimeJava version, but build-tools doesn't support all of them, so test
204-
// with compiler instead on the ones that are too old.
205-
if (project.runtimeJavaVersion <= JavaVersion.VERSION_1_10) {
206-
jvm = "${project.compilerJavaHome}/bin/java"
207-
}
208-
}
209-
210202
// This can't be an RandomizedTestingTask because we can't yet reference it
211203
task integTest(type: Test) {
212204
// integration test requires the local testing repo for example plugin builds

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -722,11 +722,7 @@ class BuildPlugin implements Plugin<Project> {
722722

723723
/** Adds compiler settings to the project */
724724
static void configureCompile(Project project) {
725-
if (project.compilerJavaVersion < JavaVersion.VERSION_1_10) {
726-
project.ext.compactProfile = 'compact3'
727-
} else {
728-
project.ext.compactProfile = 'full'
729-
}
725+
project.ext.compactProfile = 'full'
730726
project.afterEvaluate {
731727
project.tasks.withType(JavaCompile) {
732728
final JavaVersion targetCompatibilityVersion = JavaVersion.toVersion(it.targetCompatibility)
@@ -738,13 +734,6 @@ class BuildPlugin implements Plugin<Project> {
738734
options.fork = true
739735
options.forkOptions.javaHome = compilerJavaHomeFile
740736
}
741-
if (targetCompatibilityVersion == JavaVersion.VERSION_1_8) {
742-
// compile with compact 3 profile by default
743-
// NOTE: this is just a compile time check: does not replace testing with a compact3 JRE
744-
if (project.compactProfile != 'full') {
745-
options.compilerArgs << '-profile' << project.compactProfile
746-
}
747-
}
748737
/*
749738
* -path because gradle will send in paths that don't always exist.
750739
* -missing because we have tons of missing @returns and @param.
@@ -935,9 +924,7 @@ class BuildPlugin implements Plugin<Project> {
935924
File heapdumpDir = new File(project.buildDir, 'heapdump')
936925
heapdumpDir.mkdirs()
937926
jvmArg '-XX:HeapDumpPath=' + heapdumpDir
938-
if (project.runtimeJavaVersion >= JavaVersion.VERSION_1_9) {
939-
jvmArg '--illegal-access=warn'
940-
}
927+
jvmArg '--illegal-access=warn'
941928
argLine System.getProperty('tests.jvm.argline')
942929

943930
// we use './temp' since this is per JVM and tests are forbidden from writing to CWD

buildSrc/src/main/groovy/org/elasticsearch/gradle/precommit/PrecommitTasks.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ class PrecommitTasks {
131131
ExportElasticsearchBuildResourcesTask buildResources = project.tasks.getByName('buildResources')
132132
project.tasks.withType(CheckForbiddenApis) {
133133
dependsOn(buildResources)
134-
targetCompatibility = project.runtimeJavaVersion >= JavaVersion.VERSION_1_9 ?
135-
project.runtimeJavaVersion.getMajorVersion() : project.runtimeJavaVersion
134+
targetCompatibility = project.runtimeJavaVersion.getMajorVersion()
136135
if (project.runtimeJavaVersion > JavaVersion.VERSION_11) {
137136
doLast {
138137
project.logger.info(

buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class VagrantTestPlugin implements Plugin<Project> {
280280
else
281281
test_args=( "\$@" )
282282
fi
283-
java -cp "\$PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\${test_args[@]}"
283+
"\$SYSTEM_JAVA_HOME"/bin/java -cp "\$PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner "\${test_args[@]}"
284284
"""
285285
}
286286
Task createWindowsRunnerScript = project.tasks.create('createWindowsRunnerScript', FileContentsTask) {
@@ -294,7 +294,7 @@ class VagrantTestPlugin implements Plugin<Project> {
294294
} else {
295295
\$testArgs = \$args
296296
}
297-
java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
297+
"\$Env:SYSTEM_JAVA_HOME"/bin/java -cp "\$Env:PACKAGING_TESTS/*" org.elasticsearch.packaging.VMTestRunner @testArgs
298298
exit \$LASTEXITCODE
299299
"""
300300
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.12
1+
12
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8
1+
11

distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersion.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
public class JavaVersion {
2727

2828
public static final List<Integer> CURRENT = parse(System.getProperty("java.specification.version"));
29-
public static final List<Integer> JAVA_8 = parse("1.8");
29+
public static final List<Integer> JAVA_11 = parse("11");
3030

3131
static List<Integer> parse(final String value) {
3232
if (!value.matches("^0*[0-9]+(\\.[0-9]+)*$")) {

0 commit comments

Comments
 (0)