From 0843481cc5c4cb1d53df327487827f3ba59e8508 Mon Sep 17 00:00:00 2001 From: Greg Turnquist Date: Wed, 13 Nov 2019 08:29:51 -0600 Subject: [PATCH] DATAES-690 - Enable JDK 11+ builds. --- .travis.yml | 5 +- Jenkinsfile | 45 +++++++++- pom.xml | 2 +- .../org/elasticsearch/bootstrap/JarHell.java | 85 +++++++++++++++++++ 4 files changed, 129 insertions(+), 8 deletions(-) create mode 100644 src/test/java/org/elasticsearch/bootstrap/JarHell.java diff --git a/.travis.yml b/.travis.yml index 0b2b9427..c15c7007 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ dist: xenial language: java -jdk: - - openjdk8 +sudo: true -script: "mvn clean dependency:list test -Dsort -U -B" +script: "./mvnw -Pjava11 clean dependency:list test -Dsort -U -B" diff --git a/Jenkinsfile b/Jenkinsfile index 6a62bb69..a1f7efeb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,28 @@ pipeline { } stages { - stage("Test") { + stage("test: baseline (jdk8)") { + when { + anyOf { + branch 'master' + not { triggeredBy 'UpstreamCause' } + } + } + agent { + docker { + image 'adoptopenjdk/openjdk8:latest' + label 'data' + args '-v $HOME:/tmp/jenkins-home' + } + } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + sh 'rm -rf ?' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Dsort -U -B' + } + } + + stage("Test other configurations") { when { anyOf { branch 'master' @@ -20,10 +41,10 @@ pipeline { } } parallel { - stage("test: baseline") { + stage("test: baseline (jdk11)") { agent { docker { - image 'adoptopenjdk/openjdk8:latest' + image 'adoptopenjdk/openjdk11:latest' label 'data' args '-v $HOME:/tmp/jenkins-home' } @@ -31,11 +52,27 @@ pipeline { options { timeout(time: 30, unit: 'MINUTES') } steps { sh 'rm -rf ?' - sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw clean dependency:list test -Dsort -U -B' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B' + } + } + + stage("test: baseline (jdk12)") { + agent { + docker { + image 'adoptopenjdk/openjdk12:latest' + label 'data' + args '-v $HOME:/tmp/jenkins-home' + } + } + options { timeout(time: 30, unit: 'MINUTES') } + steps { + sh 'rm -rf ?' + sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pjava11 clean dependency:list test -Dsort -U -B' } } } } + stage('Release to artifactory') { when { anyOf { diff --git a/pom.xml b/pom.xml index d790d675..7d8a6880 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.springframework.data.build spring-data-parent - 2.3.0.BUILD-SNAPSHOT + 2.3.0.JDK11-SNAPSHOT Spring Data Elasticsearch diff --git a/src/test/java/org/elasticsearch/bootstrap/JarHell.java b/src/test/java/org/elasticsearch/bootstrap/JarHell.java new file mode 100644 index 00000000..3b939ddf --- /dev/null +++ b/src/test/java/org/elasticsearch/bootstrap/JarHell.java @@ -0,0 +1,85 @@ +/* + * Copyright 2018-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.elasticsearch.bootstrap; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Collections; +import java.util.Set; +import java.util.function.Consumer; + +/** + * No words – No words can describe this piece of code and why we cannot opt-in/opt-out from JarHell check. + *

+ * Elasticsearch wants to raise awareness if there are two classes with the exact same name (class name and package + * name) to avoid downstream issues. Turns out, in some case, such as Java 9 module descriptors, it's perfectly fine to + * have exactly same class names (such as {@code module-info.class}) yet JarHell goes awry and prevents startup. + *

+ * This class is here to be loaded before ES's JarHell class and to anyone that wants to survive JarHell, leave it here + * or you will die a slow and painful death. + *

+ * Oh, by the way: If Elasticsearch decides to upgrade JarHell with new method signatures, we should adapt to these. + * + * @author Mark Paluch + */ +public class JarHell { + + private JarHell() {} + + /** + * Empty stub. Leave it here or you will die a slow and painful death. + * + * @param output + * @throws IOException + * @throws URISyntaxException + */ + public static void checkJarHell(Consumer output) throws IOException, URISyntaxException {} + + /** + * Empty stub. Leave it here or you will die a slow and painful death. + * + * @return + */ + public static Set parseClassPath() { + return Collections.emptySet(); + } + + /** + * Empty stub. Leave it here or you will die a slow and painful death. + * + * @param urls + * @param output + * @throws URISyntaxException + * @throws IOException + */ + public static void checkJarHell(Set urls, Consumer output) throws URISyntaxException, IOException {} + + /** + * Empty stub. Leave it here or you will die a slow and painful death. + * + * @param targetVersion + */ + public static void checkVersionFormat(String targetVersion) {} + + /** + * Empty stub. Leave it here or you will die a slow and painful death. + * + * @param resource + * @param targetVersion + */ + public static void checkJavaVersion(String resource, String targetVersion) {} +}