Browse Source

Revert "Update to Gradle 7.6 (#89796)" (#92241)

We have seen reports of broken compilation after a clean build
after updating to gradle 7.6.

This reverts commit deaf92878aced3370af8cff08507c625dca6c0f5.
Rene Groeschke 2 years ago
parent
commit
8b9f3b595f
20 changed files with 37 additions and 59 deletions
  1. 2 3
      build-tools-internal/gradle/wrapper/gradle-wrapper.properties
  2. 1 2
      build-tools-internal/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle
  3. 1 6
      build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java
  4. 12 11
      build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java
  5. 1 4
      build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/DistroTestPlugin.java
  6. 1 1
      build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/StandaloneRestTestPlugin.java
  7. 2 3
      build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rerun/executer/RerunTestResultProcessor.java
  8. 1 1
      build-tools-internal/src/main/resources/minimumGradleVersion
  9. 3 4
      build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/test/rerun/executer/RerunTestResultProcessorTestSpec.groovy
  10. 0 2
      build-tools/src/integTest/groovy/org/elasticsearch/gradle/test/JavaRestTestPluginFuncTest.groovy
  11. 0 2
      build-tools/src/integTest/groovy/org/elasticsearch/gradle/test/YamlRestTestPluginFuncTest.groovy
  12. 1 1
      build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java
  13. 1 1
      build.gradle
  14. BIN
      gradle/wrapper/gradle-wrapper.jar
  15. 2 3
      gradle/wrapper/gradle-wrapper.properties
  16. 4 8
      gradlew
  17. 0 1
      gradlew.bat
  18. 1 1
      libs/x-content/build.gradle
  19. 2 3
      plugins/examples/gradle/wrapper/gradle-wrapper.properties
  20. 2 2
      plugins/examples/settings.gradle

+ 2 - 3
build-tools-internal/gradle/wrapper/gradle-wrapper.properties

@@ -1,7 +1,6 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
-networkTimeout=10000
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionSha256Sum=312eb12875e1747e05c2f81a4789902d7e4ec5defbd1eefeaccc08acf096505d
+distributionSha256Sum=db9c8211ed63f61f60292c69e80d89196f9eb36665e369e7f00ac4cc841c2219

+ 1 - 2
build-tools-internal/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle

@@ -28,8 +28,7 @@ configure(allprojects) {
     }
     project.tasks.withType(Test).configureEach { Test test ->
         if (BuildParams.getIsRuntimeJavaHomeSet()) {
-            test.executable = "${BuildParams.runtimeJavaHome}/bin/java" +
-                    (OS.current() == OS.WINDOWS ? '.exe' : '')
+            test.executable = "${BuildParams.runtimeJavaHome}/bin/java"
         } else {
             test.dependsOn(project.jdks.provisioned_runtime)
             test.executable = rootProject.jdks.provisioned_runtime.getBinJavaPath()

+ 1 - 6
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java

@@ -152,16 +152,11 @@ public class Jdk implements Buildable, Iterable<File> {
         return new Object() {
             @Override
             public String toString() {
-                return getHomeRoot() + getPlatformBinPath();
+                return getHomeRoot() + "/bin/java";
             }
         };
     }
 
-    private String getPlatformBinPath() {
-        boolean isWindows = "windows".equals(getPlatform());
-        return "/bin/java" + (isWindows ? ".exe" : "");
-    }
-
     public Object getJavaHomePath() {
         return new Object() {
             @Override

+ 12 - 11
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java

@@ -102,7 +102,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
                 )
             );
             params.setIsRuntimeJavaHomeSet(isRuntimeJavaHomeSet);
-            JvmInstallationMetadata runtimeJdkMetaData = metadataDetector.getMetadata(getJavaInstallation(runtimeJavaHome));
+            JvmInstallationMetadata runtimeJdkMetaData = metadataDetector.getMetadata(getJavaInstallation(runtimeJavaHome).getLocation());
             params.setRuntimeJavaDetails(formatJavaVendorDetails(runtimeJdkMetaData));
             params.setJavaVersions(getAvailableJavaVersions());
             params.setMinimumCompilerVersion(minimumCompilerVersion);
@@ -133,7 +133,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
     private Provider<MetadataBasedToolChainMatcher> resolveToolchainSpecFromEnv() {
         return providers.environmentVariable("JAVA_TOOLCHAIN_HOME").map(toolChainEnvVariable -> {
             File toolChainDir = new File(toolChainEnvVariable);
-            JvmInstallationMetadata metadata = metadataDetector.getMetadata(getJavaInstallation(toolChainDir));
+            JvmInstallationMetadata metadata = metadataDetector.getMetadata(toolChainDir);
             if (metadata.isValidInstallation() == false) {
                 throw new GradleException(
                     "Configured JAVA_TOOLCHAIN_HOME " + toolChainEnvVariable + " does not point to a valid jdk installation."
@@ -166,17 +166,17 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
         final String osVersion = System.getProperty("os.version");
         final String osArch = System.getProperty("os.arch");
         final Jvm gradleJvm = Jvm.current();
-        JvmInstallationMetadata gradleJvmMetadata = metadataDetector.getMetadata(getJavaInstallation(gradleJvm.getJavaHome()));
+        JvmInstallationMetadata gradleJvmMetadata = metadataDetector.getMetadata(gradleJvm.getJavaHome());
         final String gradleJvmVendorDetails = gradleJvmMetadata.getVendor().getDisplayName();
-        final String gradleJvmImplementationVersion = gradleJvmMetadata.getJvmVersion();
+        final String gradleJvmImplementationVersion = gradleJvmMetadata.getImplementationVersion();
         LOGGER.quiet("=======================================");
         LOGGER.quiet("Elasticsearch Build Hamster says Hello!");
         LOGGER.quiet("  Gradle Version        : " + GradleVersion.current().getVersion());
         LOGGER.quiet("  OS Info               : " + osName + " " + osVersion + " (" + osArch + ")");
         if (BuildParams.getIsRuntimeJavaHomeSet()) {
-            JvmInstallationMetadata runtimeJvm = metadataDetector.getMetadata(getJavaInstallation(BuildParams.getRuntimeJavaHome()));
+            JvmInstallationMetadata runtimeJvm = metadataDetector.getMetadata(BuildParams.getRuntimeJavaHome());
             final String runtimeJvmVendorDetails = runtimeJvm.getVendor().getDisplayName();
-            final String runtimeJvmImplementationVersion = runtimeJvm.getJvmVersion();
+            final String runtimeJvmImplementationVersion = runtimeJvm.getImplementationVersion();
             final String runtimeVersion = runtimeJvm.getRuntimeVersion();
             final String runtimeExtraDetails = runtimeJvmVendorDetails + ", " + runtimeVersion;
             LOGGER.quiet("  Runtime JDK Version   : " + runtimeJvmImplementationVersion + " (" + runtimeExtraDetails + ")");
@@ -198,7 +198,7 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
 
     private JavaVersion determineJavaVersion(String description, File javaHome, JavaVersion requiredVersion) {
         InstallationLocation installation = getJavaInstallation(javaHome);
-        JavaVersion actualVersion = metadataDetector.getMetadata(installation).getLanguageVersion();
+        JavaVersion actualVersion = metadataDetector.getMetadata(installation.getLocation()).getLanguageVersion();
         if (actualVersion.isCompatibleWith(requiredVersion) == false) {
             throwInvalidJavaHomeException(
                 description,
@@ -231,9 +231,10 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
      */
     private List<JavaHome> getAvailableJavaVersions() {
         return getAvailableJavaInstallationLocationSteam().map(installationLocation -> {
-            JvmInstallationMetadata metadata = metadataDetector.getMetadata(installationLocation);
+            File installationDir = installationLocation.getLocation();
+            JvmInstallationMetadata metadata = metadataDetector.getMetadata(installationDir);
             int actualVersion = Integer.parseInt(metadata.getLanguageVersion().getMajorVersion());
-            return JavaHome.of(actualVersion, providers.provider(() -> installationLocation.getLocation()));
+            return JavaHome.of(actualVersion, providers.provider(() -> installationDir));
         }).collect(Collectors.toList());
     }
 
@@ -356,8 +357,8 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
         }
 
         @Override
-        public JvmInstallationMetadata getMetadata(InstallationLocation installationLocation) {
-            JvmInstallationMetadata metadata = delegate.getMetadata(installationLocation);
+        public JvmInstallationMetadata getMetadata(File file) {
+            JvmInstallationMetadata metadata = delegate.getMetadata(file);
             if (metadata instanceof JvmInstallationMetadata.FailureInstallationMetadata) {
                 throw new GradleException("Jvm Metadata cannot be resolved for " + metadata.getJavaHome().toString());
             }

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

@@ -127,10 +127,7 @@ public class DistroTestPlugin implements Plugin<Project> {
             depsTask.configure(t -> t.dependsOn(examplePlugin.getDependencies()));
             depsTasks.put(taskname, depsTask);
             TaskProvider<Test> destructiveTask = configureTestTask(project, taskname, distribution, t -> {
-                t.onlyIf(
-                    "Docker is not available",
-                    t2 -> distribution.isDocker() == false || dockerSupport.get().getDockerAvailability().isAvailable()
-                );
+                t.onlyIf(t2 -> distribution.isDocker() == false || dockerSupport.get().getDockerAvailability().isAvailable());
                 addDistributionSysprop(t, DISTRIBUTION_SYSPROP, distribution::getFilepath);
                 addDistributionSysprop(t, EXAMPLE_PLUGIN_SYSPROP, () -> examplePlugin.getSingleFile().toString());
                 t.exclude("**/PackageUpgradeTests.class");

+ 1 - 1
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/StandaloneRestTestPlugin.java

@@ -71,7 +71,7 @@ public class StandaloneRestTestPlugin implements Plugin<Project> {
             );
 
         IdeaModel idea = project.getExtensions().getByType(IdeaModel.class);
-        idea.getModule().getTestSources().from(testSourceSet.getJava().getSrcDirs());
+        idea.getModule().getTestSourceDirs().addAll(testSourceSet.getJava().getSrcDirs());
         idea.getModule()
             .getScopes()
             .put(

+ 2 - 3
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rerun/executer/RerunTestResultProcessor.java

@@ -12,7 +12,6 @@ import org.gradle.api.internal.tasks.testing.TestCompleteEvent;
 import org.gradle.api.internal.tasks.testing.TestDescriptorInternal;
 import org.gradle.api.internal.tasks.testing.TestResultProcessor;
 import org.gradle.api.internal.tasks.testing.TestStartEvent;
-import org.gradle.api.tasks.testing.TestFailure;
 import org.gradle.api.tasks.testing.TestOutputEvent;
 
 import java.util.ArrayList;
@@ -90,11 +89,11 @@ final class RerunTestResultProcessor implements TestResultProcessor {
     }
 
     @Override
-    public void failure(Object testId, TestFailure result) {
+    public void failure(Object testId, Throwable throwable) {
         if (activeDescriptorsById.containsKey(testId)) {
             activeDescriptorsById.remove(testId);
             try {
-                delegate.failure(testId, result);
+                delegate.failure(testId, throwable);
             } catch (IllegalArgumentException illegalArgumentException) {
                 logTracing(testId, illegalArgumentException);
             }

+ 1 - 1
build-tools-internal/src/main/resources/minimumGradleVersion

@@ -1 +1 @@
-7.6
+7.5.1

+ 3 - 4
build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/test/rerun/executer/RerunTestResultProcessorTestSpec.groovy

@@ -12,7 +12,6 @@ import org.gradle.api.internal.tasks.testing.TestCompleteEvent
 import org.gradle.api.internal.tasks.testing.TestDescriptorInternal
 import org.gradle.api.internal.tasks.testing.TestResultProcessor
 import org.gradle.api.internal.tasks.testing.TestStartEvent
-import org.gradle.api.tasks.testing.TestFailure
 import org.gradle.api.tasks.testing.TestOutputEvent
 import spock.lang.Specification
 
@@ -76,20 +75,20 @@ class RerunTestResultProcessorTestSpec extends Specification {
 
         def testDescriptor2 = descriptor("testId2")
         def testStartEvent2 = startEvent("testId2")
-        def testFailure = Mock(TestFailure)
+        def testError2 = Mock(Throwable)
 
         when:
         processor.started(rootDescriptor, rootTestStartEvent)
         processor.started(testDescriptor1, testStartEvent1)
         processor.started(testDescriptor2, testStartEvent2)
-        processor.failure("testId2", testFailure)
+        processor.failure("testId2", testError2)
         processor.completed("rootId", rootCompleteEvent)
 
         then:
         1 * delegate.started(rootDescriptor, rootTestStartEvent)
         1 * delegate.started(testDescriptor1, testStartEvent1)
         1 * delegate.started(testDescriptor2, testStartEvent2)
-        1 * delegate.failure("testId2", testFailure)
+        1 * delegate.failure("testId2", testError2)
         0 * delegate.completed("rootId", rootCompleteEvent)
 
         when:

+ 0 - 2
build-tools/src/integTest/groovy/org/elasticsearch/gradle/test/JavaRestTestPluginFuncTest.groovy

@@ -11,7 +11,6 @@ package org.elasticsearch.gradle.test
 import org.elasticsearch.gradle.VersionProperties
 import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
 import org.gradle.testkit.runner.TaskOutcome
-import spock.lang.Ignore
 
 class JavaRestTestPluginFuncTest extends AbstractGradleFuncTest {
 
@@ -20,7 +19,6 @@ class JavaRestTestPluginFuncTest extends AbstractGradleFuncTest {
         configurationCacheCompatible = false
     }
 
-    @Ignore('https://github.com/gradle/gradle/issues/21868')
     def "declares default dependencies"() {
         given:
         buildFile << """

+ 0 - 2
build-tools/src/integTest/groovy/org/elasticsearch/gradle/test/YamlRestTestPluginFuncTest.groovy

@@ -11,7 +11,6 @@ package org.elasticsearch.gradle.test
 import org.elasticsearch.gradle.VersionProperties
 import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
 import org.gradle.testkit.runner.TaskOutcome
-import spock.lang.Ignore
 
 class YamlRestTestPluginFuncTest extends AbstractGradleFuncTest {
 
@@ -20,7 +19,6 @@ class YamlRestTestPluginFuncTest extends AbstractGradleFuncTest {
         configurationCacheCompatible = false
     }
 
-    @Ignore('https://github.com/gradle/gradle/issues/21868')
     def "declares default dependencies"() {
         given:
         buildFile << """

+ 1 - 1
build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java

@@ -127,7 +127,7 @@ public abstract class GradleUtils {
         Configuration runtimeClasspathConfiguration = project.getConfigurations().getByName(runtimeClasspathName);
         project.getPluginManager().withPlugin("idea", p -> {
             IdeaModel idea = project.getExtensions().getByType(IdeaModel.class);
-            idea.getModule().getTestSources().from(testSourceSet.getJava().getSrcDirs());
+            idea.getModule().setTestSourceDirs(testSourceSet.getJava().getSrcDirs());
             idea.getModule().getScopes().put(testSourceSet.getName(), Map.of("plus", List.of(runtimeClasspathConfiguration)));
         });
         project.getPluginManager().withPlugin("eclipse", p -> {

+ 1 - 1
build.gradle

@@ -19,7 +19,7 @@ import org.elasticsearch.gradle.internal.info.BuildParams
 import org.elasticsearch.gradle.util.GradleUtils
 import org.gradle.plugins.ide.eclipse.model.AccessRule
 import org.gradle.plugins.ide.eclipse.model.ProjectDependency
-import org.gradle.util.internal.DistributionLocator
+import org.gradle.util.DistributionLocator
 import org.gradle.util.GradleVersion
 
 import java.nio.file.Files

BIN
gradle/wrapper/gradle-wrapper.jar


+ 2 - 3
gradle/wrapper/gradle-wrapper.properties

@@ -1,7 +1,6 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
-networkTimeout=10000
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionSha256Sum=312eb12875e1747e05c2f81a4789902d7e4ec5defbd1eefeaccc08acf096505d
+distributionSha256Sum=db9c8211ed63f61f60292c69e80d89196f9eb36665e369e7f00ac4cc841c2219

+ 4 - 8
gradlew

@@ -55,7 +55,7 @@
 #       Darwin, MinGW, and NonStop.
 #
 #   (3) This script is generated from the Groovy template
-#       https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+#       https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
 #       within the Gradle project.
 #
 #       You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,11 +80,11 @@ do
     esac
 done
 
-# This is normally unused
-# shellcheck disable=SC2034
-APP_BASE_NAME=${0##*/}
 APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
 
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
 # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
 DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
 
@@ -143,16 +143,12 @@ fi
 if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
     case $MAX_FD in #(
       max*)
-        # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
-        # shellcheck disable=SC3045 
         MAX_FD=$( ulimit -H -n ) ||
             warn "Could not query maximum file descriptor limit"
     esac
     case $MAX_FD in  #(
       '' | soft) :;; #(
       *)
-        # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
-        # shellcheck disable=SC3045 
         ulimit -n "$MAX_FD" ||
             warn "Could not set maximum file descriptor limit to $MAX_FD"
     esac

+ 0 - 1
gradlew.bat

@@ -26,7 +26,6 @@ if "%OS%"=="Windows_NT" setlocal
 
 set DIRNAME=%~dp0
 if "%DIRNAME%"=="" set DIRNAME=.
-@rem This is normally unused
 set APP_BASE_NAME=%~n0
 set APP_HOME=%DIRNAME%
 

+ 1 - 1
libs/x-content/build.gradle

@@ -69,7 +69,7 @@ tasks.named("dependencyLicenses").configure {
 File generatedResourcesDir = new File(buildDir, 'generated-resources')
 def generateProviderManifest = tasks.register("generateProviderManifest") {
   File manifestFile = new File(generatedResourcesDir, "LISTING.TXT")
-  inputs.files('jars', configurations.providerImpl).withPathSensitivity(PathSensitivity.RELATIVE)
+  inputs.property('jars', configurations.providerImpl)
   outputs.file(manifestFile)
   doLast {
     manifestFile.parentFile.mkdirs()

+ 2 - 3
plugins/examples/gradle/wrapper/gradle-wrapper.properties

@@ -1,7 +1,6 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
-networkTimeout=10000
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionSha256Sum=312eb12875e1747e05c2f81a4789902d7e4ec5defbd1eefeaccc08acf096505d
+distributionSha256Sum=db9c8211ed63f61f60292c69e80d89196f9eb36665e369e7f00ac4cc841c2219

+ 2 - 2
plugins/examples/settings.gradle

@@ -36,8 +36,8 @@ gradle.projectsEvaluated {
           // When using composite builds we need to tell Gradle to use the project names since we rename the published artifacts
           substitute module('org.elasticsearch:elasticsearch') using module("org.elasticsearch:server:${elasticsearchVersion}")
           substitute module('org.elasticsearch.client:elasticsearch-rest-client') using module("org.elasticsearch.client:rest:${elasticsearchVersion}")
-          substitute module('org.elasticsearch.plugin:x-pack-core') using module("org.elasticsearch.plugin:core:${elasticsearchVersion}")
-          substitute module('org.elasticsearch.plugin:elasticsearch-scripting-painless-spi') using module("org.elasticsearch.plugin:spi:${elasticsearchVersion}")
+          substitute module('org.elasticsearch.plugin:x-pack-core') with module("org.elasticsearch.plugin:core:${elasticsearchVersion}")
+          substitute module('org.elasticsearch.plugin:elasticsearch-scripting-painless-spi') with module("org.elasticsearch.plugin:spi:${elasticsearchVersion}")
           substitute module('org.elasticsearch.distribution.integ-test-zip:elasticsearch') using variant(module("org.elasticsearch.distribution.integ-test-zip:integ-test-zip:${elasticsearchVersion}")) {
             attributes {
               attribute(Attribute.of("composite", Boolean.class), true)