Browse Source

Update Gradle Wrapper to 7.6.1 (#89796) (#92241) (#94122)

This updates the gradle wrapper to 7.6.1. This patch release contains a
fix for  incremental compilation of java modules we have raised against
gradle 7.6

see https://github.com/gradle/gradle/issues/23067
Rene Groeschke 2 years ago
parent
commit
08845b78f2
20 changed files with 59 additions and 37 deletions
  1. 3 2
      build-tools-internal/gradle/wrapper/gradle-wrapper.properties
  2. 2 1
      build-tools-internal/src/main/groovy/elasticsearch.runtime-jdk-provision.gradle
  3. 6 1
      build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/Jdk.java
  4. 11 12
      build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java
  5. 4 1
      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. 3 2
      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. 4 3
      build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/test/rerun/executer/RerunTestResultProcessorTestSpec.groovy
  10. 2 0
      build-tools/src/integTest/groovy/org/elasticsearch/gradle/test/JavaRestTestPluginFuncTest.groovy
  11. 2 0
      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. 3 2
      gradle/wrapper/gradle-wrapper.properties
  16. 8 4
      gradlew
  17. 1 0
      gradlew.bat
  18. 1 1
      libs/x-content/build.gradle
  19. 3 2
      plugins/examples/gradle/wrapper/gradle-wrapper.properties
  20. 2 2
      plugins/examples/settings.gradle

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

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

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

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

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

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

+ 11 - 12
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).getLocation());
+            JvmInstallationMetadata runtimeJdkMetaData = metadataDetector.getMetadata(getJavaInstallation(runtimeJavaHome));
             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(toolChainDir);
+            JvmInstallationMetadata metadata = metadataDetector.getMetadata(getJavaInstallation(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(gradleJvm.getJavaHome());
+        JvmInstallationMetadata gradleJvmMetadata = metadataDetector.getMetadata(getJavaInstallation(gradleJvm.getJavaHome()));
         final String gradleJvmVendorDetails = gradleJvmMetadata.getVendor().getDisplayName();
-        final String gradleJvmImplementationVersion = gradleJvmMetadata.getImplementationVersion();
+        final String gradleJvmImplementationVersion = gradleJvmMetadata.getJvmVersion();
         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(BuildParams.getRuntimeJavaHome());
+            JvmInstallationMetadata runtimeJvm = metadataDetector.getMetadata(getJavaInstallation(BuildParams.getRuntimeJavaHome()));
             final String runtimeJvmVendorDetails = runtimeJvm.getVendor().getDisplayName();
-            final String runtimeJvmImplementationVersion = runtimeJvm.getImplementationVersion();
+            final String runtimeJvmImplementationVersion = runtimeJvm.getJvmVersion();
             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.getLocation()).getLanguageVersion();
+        JavaVersion actualVersion = metadataDetector.getMetadata(installation).getLanguageVersion();
         if (actualVersion.isCompatibleWith(requiredVersion) == false) {
             throwInvalidJavaHomeException(
                 description,
@@ -231,10 +231,9 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
      */
     private List<JavaHome> getAvailableJavaVersions() {
         return getAvailableJavaInstallationLocationSteam().map(installationLocation -> {
-            File installationDir = installationLocation.getLocation();
-            JvmInstallationMetadata metadata = metadataDetector.getMetadata(installationDir);
+            JvmInstallationMetadata metadata = metadataDetector.getMetadata(installationLocation);
             int actualVersion = Integer.parseInt(metadata.getLanguageVersion().getMajorVersion());
-            return JavaHome.of(actualVersion, providers.provider(() -> installationDir));
+            return JavaHome.of(actualVersion, providers.provider(() -> installationLocation.getLocation()));
         }).collect(Collectors.toList());
     }
 
@@ -357,8 +356,8 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
         }
 
         @Override
-        public JvmInstallationMetadata getMetadata(File file) {
-            JvmInstallationMetadata metadata = delegate.getMetadata(file);
+        public JvmInstallationMetadata getMetadata(InstallationLocation installationLocation) {
+            JvmInstallationMetadata metadata = delegate.getMetadata(installationLocation);
             if (metadata instanceof JvmInstallationMetadata.FailureInstallationMetadata) {
                 throw new GradleException("Jvm Metadata cannot be resolved for " + metadata.getJavaHome().toString());
             }

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

@@ -127,7 +127,10 @@ 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(t2 -> distribution.isDocker() == false || dockerSupport.get().getDockerAvailability().isAvailable());
+                t.onlyIf(
+                    "Docker is not available",
+                    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().getTestSourceDirs().addAll(testSourceSet.getJava().getSrcDirs());
+        idea.getModule().getTestSources().from(testSourceSet.getJava().getSrcDirs());
         idea.getModule()
             .getScopes()
             .put(

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

@@ -12,6 +12,7 @@ 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;
@@ -89,11 +90,11 @@ final class RerunTestResultProcessor implements TestResultProcessor {
     }
 
     @Override
-    public void failure(Object testId, Throwable throwable) {
+    public void failure(Object testId, TestFailure result) {
         if (activeDescriptorsById.containsKey(testId)) {
             activeDescriptorsById.remove(testId);
             try {
-                delegate.failure(testId, throwable);
+                delegate.failure(testId, result);
             } catch (IllegalArgumentException illegalArgumentException) {
                 logTracing(testId, illegalArgumentException);
             }

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

@@ -1 +1 @@
-7.5.1
+7.6.1

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

@@ -12,6 +12,7 @@ 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
 
@@ -75,20 +76,20 @@ class RerunTestResultProcessorTestSpec extends Specification {
 
         def testDescriptor2 = descriptor("testId2")
         def testStartEvent2 = startEvent("testId2")
-        def testError2 = Mock(Throwable)
+        def testFailure = Mock(TestFailure)
 
         when:
         processor.started(rootDescriptor, rootTestStartEvent)
         processor.started(testDescriptor1, testStartEvent1)
         processor.started(testDescriptor2, testStartEvent2)
-        processor.failure("testId2", testError2)
+        processor.failure("testId2", testFailure)
         processor.completed("rootId", rootCompleteEvent)
 
         then:
         1 * delegate.started(rootDescriptor, rootTestStartEvent)
         1 * delegate.started(testDescriptor1, testStartEvent1)
         1 * delegate.started(testDescriptor2, testStartEvent2)
-        1 * delegate.failure("testId2", testError2)
+        1 * delegate.failure("testId2", testFailure)
         0 * delegate.completed("rootId", rootCompleteEvent)
 
         when:

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

@@ -11,6 +11,7 @@ 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 {
 
@@ -19,6 +20,7 @@ class JavaRestTestPluginFuncTest extends AbstractGradleFuncTest {
         configurationCacheCompatible = false
     }
 
+    @Ignore('https://github.com/gradle/gradle/issues/21868')
     def "declares default dependencies"() {
         given:
         buildFile << """

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

@@ -11,6 +11,7 @@ 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 {
 
@@ -19,6 +20,7 @@ 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().setTestSourceDirs(testSourceSet.getJava().getSrcDirs());
+            idea.getModule().getTestSources().from(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.DistributionLocator
+import org.gradle.util.internal.DistributionLocator
 import org.gradle.util.GradleVersion
 
 import java.nio.file.Files

BIN
gradle/wrapper/gradle-wrapper.jar


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

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

+ 8 - 4
gradlew

@@ -55,7 +55,7 @@
 #       Darwin, MinGW, and NonStop.
 #
 #   (3) This script is generated from the Groovy template
-#       https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+#       https://github.com/gradle/gradle/blob/HEAD/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,10 +80,10 @@ do
     esac
 done
 
-APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
-
-APP_NAME="Gradle"
+# This is normally unused
+# shellcheck disable=SC2034
 APP_BASE_NAME=${0##*/}
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
 
 # 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,12 +143,16 @@ 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

+ 1 - 0
gradlew.bat

@@ -26,6 +26,7 @@ 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.property('jars', configurations.providerImpl)
+  inputs.files('jars', configurations.providerImpl).withPathSensitivity(PathSensitivity.RELATIVE)
   outputs.file(manifestFile)
   doLast {
     manifestFile.parentFile.mkdirs()

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

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

+ 2 - 2
plugins/examples/settings.gradle

@@ -38,8 +38,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') 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.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.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)