From d94afd970af032b0feabc82b821a00a1d2c36ca1 Mon Sep 17 00:00:00 2001 From: jaymode Date: Thu, 21 Nov 2019 10:39:14 -0700 Subject: [PATCH 1/4] Run build-tools test with compiler jdk The test task is configured to use the runtime java version, but there are issues with the version of groovy used by gradle pre 6.0. In order to workaround this, we use the compiler java to execute the build-tools tests. Closes #49404 --- buildSrc/build.gradle | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 934990a1dbc52..3d4fd5320671f 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -215,16 +215,34 @@ if (project != rootProject) { } } + // use an object to lazy initialize the executable to avoid accessing the runtime java + // version during configuration + Object testExecutableEvaluator = new Object() { + @Override + public String toString() { + return org.elasticsearch.gradle.info.BuildParams.runtimeJavaVersion > JavaVersion.VERSION_12 ? + org.elasticsearch.gradle.info.BuildParams.compilerJavaHome.toString() + "/bin/java" : + org.elasticsearch.gradle.info.BuildParams.runtimeJavaHome.toString() + "/bin/java" + } + } + + test { + // run build-tools tests with the compiler Java to workaround issues with JDK13+ and Groovy pre 2.5.7 + executable = testExecutableEvaluator + } + task integTest(type: Test) { inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE) systemProperty 'test.version_under_test', version onlyIf { org.elasticsearch.gradle.info.BuildParams.inFipsJvm == false } + // run build-tools tests with the compiler Java to workaround issues with JDK13+ and Groovy pre 2.5.7 + executable = testExecutableEvaluator maxParallelForks = System.getProperty('tests.jvms', org.elasticsearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer } check.dependsOn(integTest) /* - * We alread configure publication and we don't need or want this one that + * We already configure publication and we don't need or want this one that * comes from the java-gradle-plugin. */ afterEvaluate { From b6cc9869ada6f58263fc48354bc8d4ba521d2baf Mon Sep 17 00:00:00 2001 From: jaymode Date: Thu, 21 Nov 2019 13:01:22 -0700 Subject: [PATCH 2/4] don't run tests at all unless runtime jdk is set and is <= 12 --- buildSrc/build.gradle | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 3d4fd5320671f..caf54521b759b 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -215,28 +215,22 @@ if (project != rootProject) { } } - // use an object to lazy initialize the executable to avoid accessing the runtime java - // version during configuration - Object testExecutableEvaluator = new Object() { - @Override - public String toString() { - return org.elasticsearch.gradle.info.BuildParams.runtimeJavaVersion > JavaVersion.VERSION_12 ? - org.elasticsearch.gradle.info.BuildParams.compilerJavaHome.toString() + "/bin/java" : - org.elasticsearch.gradle.info.BuildParams.runtimeJavaHome.toString() + "/bin/java" - } - } test { - // run build-tools tests with the compiler Java to workaround issues with JDK13+ and Groovy pre 2.5.7 - executable = testExecutableEvaluator + // build-tools tests are not compatible with JDKs > 12 until we upgrade to Gradle 6.0+. Our current bundled JDK is always newer + // than 12 so unless runtime java home is set, we cannot run the build-tools tests + onlyIf { org.elasticsearch.gradle.info.BuildParams.getIsRuntimeJavaHomeSet() } + onlyIf { org.elasticsearch.gradle.info.BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_12 } } task integTest(type: Test) { inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE) systemProperty 'test.version_under_test', version onlyIf { org.elasticsearch.gradle.info.BuildParams.inFipsJvm == false } - // run build-tools tests with the compiler Java to workaround issues with JDK13+ and Groovy pre 2.5.7 - executable = testExecutableEvaluator + // build-tools tests are not compatible with JDKs > 12 until we upgrade to Gradle 6.0+. Our current bundled JDK is always newer + // than 12 so unless runtime java home is set, we cannot run the build-tools tests + onlyIf { org.elasticsearch.gradle.info.BuildParams.getIsRuntimeJavaHomeSet() } + onlyIf { org.elasticsearch.gradle.info.BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_12 } maxParallelForks = System.getProperty('tests.jvms', org.elasticsearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer } check.dependsOn(integTest) From 1f77355a81b893b955b20a0b64664cecf613cc86 Mon Sep 17 00:00:00 2001 From: jaymode Date: Thu, 21 Nov 2019 15:16:55 -0700 Subject: [PATCH 3/4] iteration --- buildSrc/build.gradle | 18 ++++++------------ gradle/runtime-jdk-provision.gradle | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index caf54521b759b..35ecbbc0da275 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -17,6 +17,7 @@ * under the License. */ +import org.gradle.internal.jvm.Jvm import org.gradle.util.GradleVersion plugins { @@ -215,26 +216,19 @@ if (project != rootProject) { } } - - test { - // build-tools tests are not compatible with JDKs > 12 until we upgrade to Gradle 6.0+. Our current bundled JDK is always newer - // than 12 so unless runtime java home is set, we cannot run the build-tools tests - onlyIf { org.elasticsearch.gradle.info.BuildParams.getIsRuntimeJavaHomeSet() } - onlyIf { org.elasticsearch.gradle.info.BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_12 } - } - task integTest(type: Test) { inputs.dir(file("src/testKit")).withPropertyName("testkit dir").withPathSensitivity(PathSensitivity.RELATIVE) systemProperty 'test.version_under_test', version onlyIf { org.elasticsearch.gradle.info.BuildParams.inFipsJvm == false } - // build-tools tests are not compatible with JDKs > 12 until we upgrade to Gradle 6.0+. Our current bundled JDK is always newer - // than 12 so unless runtime java home is set, we cannot run the build-tools tests - onlyIf { org.elasticsearch.gradle.info.BuildParams.getIsRuntimeJavaHomeSet() } - onlyIf { org.elasticsearch.gradle.info.BuildParams.runtimeJavaVersion <= JavaVersion.VERSION_12 } maxParallelForks = System.getProperty('tests.jvms', org.elasticsearch.gradle.info.BuildParams.defaultParallel.toString()) as Integer } check.dependsOn(integTest) + // for now we hardcode the tests for our build to use the gradle jvm. + tasks.withType(Test).configureEach { + it.executable = Jvm.current().getJavaHome().toPath().resolve("bin").resolve("java").toAbsolutePath() + } + /* * We already configure publication and we don't need or want this one that * comes from the java-gradle-plugin. diff --git a/gradle/runtime-jdk-provision.gradle b/gradle/runtime-jdk-provision.gradle index e67d1d44f507c..e05da2d47c5a6 100644 --- a/gradle/runtime-jdk-provision.gradle +++ b/gradle/runtime-jdk-provision.gradle @@ -12,7 +12,7 @@ jdks { } } -allprojects { +configure(allprojects - project(':build-tools')) { project.tasks.withType(Test).configureEach { Test test -> if (BuildParams.getIsRuntimeJavaHomeSet()) { test.executable = "${BuildParams.runtimeJavaHome}/bin/java" @@ -21,4 +21,4 @@ allprojects { test.executable = rootProject.jdks.provisioned_runtime.getBinJavaPath() } } -} \ No newline at end of file +} From 5624d76f6c6f477b93b209d66e2c0af8edb7c48e Mon Sep 17 00:00:00 2001 From: jaymode Date: Fri, 22 Nov 2019 09:22:21 -0700 Subject: [PATCH 4/4] simplify --- buildSrc/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 35ecbbc0da275..49edf5581d6ff 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -226,7 +226,7 @@ if (project != rootProject) { // for now we hardcode the tests for our build to use the gradle jvm. tasks.withType(Test).configureEach { - it.executable = Jvm.current().getJavaHome().toPath().resolve("bin").resolve("java").toAbsolutePath() + it.executable = Jvm.current().getJavaExecutable() } /*