Browse Source

Require Java 17 for running Elasticsearch (#79873)

Mark Vieira 4 years ago
parent
commit
26c86871fc

+ 1 - 1
.ci/java-versions.properties

@@ -5,4 +5,4 @@
 # are 'java' or 'openjdk' followed by the major release number.
 
 ES_BUILD_JAVA=openjdk16
-ES_RUNTIME_JAVA=java11
+ES_RUNTIME_JAVA=openjdk17

+ 0 - 5
.ci/matrix-runtime-javas.yml

@@ -6,9 +6,4 @@
 # or 'openjdk' followed by the major release number.
 
 ES_RUNTIME_JAVA:
-  - java11
-  - openjdk16
-  - zulu11
-  - corretto11
-  - adoptopenjdk11
   - openjdk17

+ 8 - 0
build-tools-internal/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle

@@ -33,4 +33,12 @@ configure(allprojects) {
             test.executable = rootProject.jdks.provisioned_runtime.getBinJavaPath()
         }
     }
+    project.plugins.withId("elasticsearch.testclusters") { testClustersPlugin ->
+        project.plugins.withId("elasticsearch.internal-testclusters") { internalPlugin ->
+            if (BuildParams.getIsRuntimeJavaHomeSet() == false) {
+                // If no runtime java home is set, use the bundled JDK for test clusters
+                testClustersPlugin.setRuntimeJava(providers.provider(() -> file("${rootProject.jdks.provisioned_runtime.javaHomePath}")))
+            }
+        }
+    }
 }

+ 10 - 2
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java

@@ -86,6 +86,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
         JavaVersion minimumRuntimeVersion = JavaVersion.toVersion(getResourceContents("/minimumRuntimeVersion"));
 
         File runtimeJavaHome = findRuntimeJavaHome();
+        boolean isRuntimeJavaHomeSet = Jvm.current().getJavaHome().equals(runtimeJavaHome) == false;
 
         File rootDir = project.getRootDir();
         GitInfo gitInfo = GitInfo.gitInfo(rootDir);
@@ -93,8 +94,15 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
         BuildParams.init(params -> {
             params.reset();
             params.setRuntimeJavaHome(runtimeJavaHome);
-            params.setRuntimeJavaVersion(determineJavaVersion("runtime java.home", runtimeJavaHome, minimumRuntimeVersion));
-            params.setIsRuntimeJavaHomeSet(Jvm.current().getJavaHome().equals(runtimeJavaHome) == false);
+            // TODO: Temporarily hard-code this to 17 until we upgrade to Gradle 7.3 and bump minimumRuntimeVersion
+            params.setRuntimeJavaVersion(
+                determineJavaVersion(
+                    "runtime java.home",
+                    runtimeJavaHome,
+                    isRuntimeJavaHomeSet ? JavaVersion.VERSION_17 : Jvm.current().getJavaVersion()
+                )
+            );
+            params.setIsRuntimeJavaHomeSet(isRuntimeJavaHomeSet);
             JvmInstallationMetadata runtimeJdkMetaData = metadataDetector.getMetadata(getJavaInstallation(runtimeJavaHome).getLocation());
             params.setRuntimeJavaDetails(formatJavaVendorDetails(runtimeJdkMetaData));
             params.setJavaVersions(getAvailableJavaVersions());

+ 2 - 2
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/DistroTestPlugin.java

@@ -69,8 +69,8 @@ import static org.elasticsearch.gradle.internal.vagrant.VagrantMachine.convertWi
  * This class defines gradle tasks for testing our various distribution artifacts.
  */
 public class DistroTestPlugin implements Plugin<Project> {
-    private static final String SYSTEM_JDK_VERSION = "11.0.2+9";
-    private static final String SYSTEM_JDK_VENDOR = "openjdk";
+    private static final String SYSTEM_JDK_VERSION = "17+35";
+    private static final String SYSTEM_JDK_VENDOR = "adoptium";
     private static final String GRADLE_JDK_VERSION = "16.0.2+7";
     private static final String GRADLE_JDK_VENDOR = "adoptium";
 

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

@@ -15,7 +15,7 @@ import java.util.Objects;
 public class JavaVersion {
 
     public static final List<Integer> CURRENT = parse(System.getProperty("java.specification.version"));
-    public static final List<Integer> JAVA_11 = parse("11");
+    public static final List<Integer> JAVA_17 = parse("17");
 
     static List<Integer> parse(final String value) {
         if (value.matches("^0*[0-9]+(\\.[0-9]+)*$") == false) {

+ 4 - 4
distribution/tools/java-version-checker/src/main/java/org/elasticsearch/tools/java_version_checker/JavaVersionChecker.java

@@ -12,14 +12,14 @@ import java.util.Arrays;
 import java.util.Locale;
 
 /**
- * Simple program that checks if the runtime Java version is at least 1.8.
+ * Simple program that checks if the runtime Java version is at least 17.
  */
 final class JavaVersionChecker {
 
     private JavaVersionChecker() {}
 
     /**
-     * The main entry point. The exit code is 0 if the Java version is at least 1.8, otherwise the exit code is 1.
+     * The main entry point. The exit code is 0 if the Java version is at least 17, otherwise the exit code is 1.
      *
      * @param args the args to the program which are rejected if not empty
      */
@@ -28,10 +28,10 @@ final class JavaVersionChecker {
         if (args.length != 0) {
             throw new IllegalArgumentException("expected zero arguments but was " + Arrays.toString(args));
         }
-        if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_11) < 0) {
+        if (JavaVersion.compare(JavaVersion.CURRENT, JavaVersion.JAVA_17) < 0) {
             final String message = String.format(
                 Locale.ROOT,
-                "the minimum required Java version is 11; your Java version from [%s] does not meet this requirement",
+                "The minimum required Java version is 17; your Java version from [%s] does not meet this requirement",
                 System.getProperty("java.home")
             );
             errPrintln(message);

+ 21 - 0
docs/changelog/79873.yaml

@@ -0,0 +1,21 @@
+pr: 79873
+summary: Require Java 17 for running Elasticsearch
+area: Packaging
+type: breaking
+issues: []
+breaking:
+  title: Require Java 17 for running Elasticsearch
+  area: Packaging
+  details: |-
+    Java 17 or higher is now required to run Elasticsearch and any of its command
+    line tools.
+  impact: |-
+    Use Java 17 or higher. Attempts to run Elasticsearch 8.0 using earlier Java versions will
+    fail.
+
+    There is not yet a FIPS-certified security module for Java 17
+    that you can use when running Elasticsearch 8.0 in FIPS 140-2 mode.
+    If you run in FIPS 140-2 mode, you will either need to request an exception
+    from your security organization to upgrade to Elasticsearch 8.0,
+    or remain on Elasticsearch 7.x until Java 17 is certified.
+  notable: true