Browse Source

Update build to use gradle wrapper 6.8 (#65596)

- Updates our build to use the latest Gradle 6.8 release which is the last release 
before the major 7.0 release. 
- Resolve available gradle versions using built-in toolchain support
- Fixes deprecated usage of JavaInstallationRegistry
- We replace jdk handling in our build to rely on jvm detection provided by the gradle build tool itself. 
As we rely on environment variables pointing to jdks we wire this into the gradle jdk detection mechanism
Rene Groeschke 4 years ago
parent
commit
a8757f9efe
21 changed files with 186 additions and 161 deletions
  1. 8 5
      buildSrc/src/integTest/groovy/org/elasticsearch/gradle/DistributionDownloadPluginFuncTest.groovy
  2. 0 7
      buildSrc/src/integTest/groovy/org/elasticsearch/gradle/ElasticsearchJavaPluginFuncTest.groovy
  3. 10 7
      buildSrc/src/integTest/groovy/org/elasticsearch/gradle/JdkDownloadPluginFuncTest.groovy
  4. 7 0
      buildSrc/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy
  5. 2 0
      buildSrc/src/integTest/java/org/elasticsearch/gradle/BuildPluginIT.java
  6. 1 1
      buildSrc/src/integTest/java/org/elasticsearch/gradle/precommit/TestingConventionsTasksIT.java
  7. 3 3
      buildSrc/src/integTest/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTaskIT.java
  8. 4 1
      buildSrc/src/integTest/resources/org/elasticsearch/gradle/internal/fake_git/remote/gradle.properties
  9. 46 54
      buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java
  10. 3 0
      buildSrc/src/main/java/org/elasticsearch/gradle/precommit/JarHellPrecommitPlugin.java
  11. 0 3
      buildSrc/src/main/java/org/elasticsearch/gradle/transform/SymbolicLinkPreservingUntarTransform.java
  12. 3 0
      buildSrc/src/main/java/org/elasticsearch/gradle/transform/UnpackTransform.java
  13. 1 1
      buildSrc/src/main/resources/minimumGradleVersion
  14. 0 73
      buildSrc/src/test/java/org/elasticsearch/gradle/plugin/PluginBuildPluginTests.java
  15. 4 4
      buildSrc/src/testFixtures/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java
  16. 22 0
      buildSrc/src/testKit/elasticsearch-build-resources/gradle.properties
  17. 22 0
      buildSrc/src/testKit/elasticsearch.build/gradle.properties
  18. 22 0
      buildSrc/src/testKit/reaper/gradle.properties
  19. 22 0
      buildSrc/src/testKit/thirdPartyAudit/gradle.properties
  20. 4 0
      gradle.properties
  21. 2 2
      gradle/wrapper/gradle-wrapper.properties

+ 8 - 5
buildSrc/src/integTest/groovy/org/elasticsearch/gradle/DistributionDownloadPluginFuncTest.groovy

@@ -20,7 +20,6 @@
 package org.elasticsearch.gradle
 
 import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
-import org.elasticsearch.gradle.transform.SymbolicLinkPreservingUntarTransform
 import org.gradle.testkit.runner.TaskOutcome
 import spock.lang.Unroll
 
@@ -61,17 +60,21 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest {
         """
 
         when:
-        def runner = gradleRunner('clean', 'setupDistro', '-i')
+        def guh = new File(testProjectDir.getRoot(), "gradle-user-home").absolutePath;
+        def runner = gradleRunner('clean', 'setupDistro', '-i', '-g', guh)
         def result = withMockedDistributionDownload(version, platform, runner) {
             // initial run
-            build()
+            def firstRun = build()
+            assertOutputContains(firstRun.output, "Unpacking elasticsearch-${version}-linux-x86_64.tar.gz " +
+                    "using SymbolicLinkPreservingUntarTransform")
             // 2nd invocation
             build()
         }
 
         then:
         result.task(":setupDistro").outcome == TaskOutcome.SUCCESS
-        assertOutputContains(result.output, "Skipping ${SymbolicLinkPreservingUntarTransform.class.simpleName}")
+        assertOutputMissing(result.output, "Unpacking elasticsearch-${version}-linux-x86_64.tar.gz " +
+                "using SymbolicLinkPreservingUntarTransform")
     }
 
     def "transforms are reused across projects"() {
@@ -109,7 +112,7 @@ class DistributionDownloadPluginFuncTest extends AbstractGradleFuncTest {
         then:
         result.tasks.size() == 3
         result.output.count("Unpacking elasticsearch-${version}-linux-x86_64.tar.gz " +
-                "using SymbolicLinkPreservingUntarTransform.") == 1
+                "using SymbolicLinkPreservingUntarTransform") == 1
     }
 
     private boolean assertExtractedDistroCreated(String relativePath) {

+ 0 - 7
buildSrc/src/integTest/groovy/org/elasticsearch/gradle/ElasticsearchJavaPluginFuncTest.groovy

@@ -58,11 +58,4 @@ class ElasticsearchJavaPluginFuncTest extends AbstractGradleFuncTest {
         then:
         gradleRunner("help").build()
     }
-
-    private File someJavaSource() {
-        file("src/main/java/org/acme/SomeClass.java") << """
-        package org.acme;
-        public class SomeClass {}
-        """
-    }
 }

+ 10 - 7
buildSrc/src/integTest/groovy/org/elasticsearch/gradle/JdkDownloadPluginFuncTest.groovy

@@ -135,7 +135,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
 
         then:
         result.tasks.size() == 3
-        result.output.count("Unpacking linux-12.0.2-x64.tar.gz using ${SymbolicLinkPreservingUntarTransform.simpleName}.") == 1
+        result.output.count("Unpacking linux-12.0.2-x64.tar.gz using ${SymbolicLinkPreservingUntarTransform.simpleName}") == 1
 
         where:
         platform | jdkVendor           | jdkVersion        | expectedJavaBin
@@ -177,18 +177,20 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
 
             def commonGradleUserHome = testProjectDir.newFolder().toString()
             // initial run
-            gradleRunner('clean', 'getJdk', '-g', commonGradleUserHome).build()
+            def firstResult = gradleRunner('clean', 'getJdk', '-i', '--warning-mode', 'all', '-g', commonGradleUserHome).build()
+            // assert the output of an executed transform is shown
+            assertOutputContains(firstResult.output, "Unpacking $expectedArchiveName using $transformType")
             // run against up-to-date transformations
-            gradleRunner('clean', 'getJdk', '-i', '-g', commonGradleUserHome).build()
+            gradleRunner('clean', 'getJdk', '-i', '--warning-mode', 'all', '-g', commonGradleUserHome).build()
         }
 
         then:
-        assertOutputContains(result.output, "Skipping $transformType")
+        normalized(result.output).contains("Unpacking $expectedArchiveName using $transformType") == false
 
         where:
-        platform  | transformType
-        "linux"   | SymbolicLinkPreservingUntarTransform.class.simpleName
-        "windows" | UnzipTransform.class.simpleName
+        platform  | expectedArchiveName       | transformType
+        "linux"   | "linux-12.0.2-x64.tar.gz" | SymbolicLinkPreservingUntarTransform.class.simpleName
+        "windows" | "windows-12.0.2-x64.zip"  | UnzipTransform.class.simpleName
     }
 
     static boolean assertExtraction(String output, String javaBin) {
@@ -237,6 +239,7 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
                     if(repo.name == "jdk_repo_${jdkVendor}_${jdkVersion}") {
                       repo.setUrl('${server.baseUrl()}')
                     }
+                    allowInsecureProtocol = true
                 }
            }"""
     }

+ 7 - 0
buildSrc/src/integTest/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy

@@ -35,11 +35,14 @@ abstract class AbstractGradleFuncTest extends Specification {
 
     File settingsFile
     File buildFile
+    File propertiesFile
 
     def setup() {
         settingsFile = testProjectDir.newFile('settings.gradle')
         settingsFile << "rootProject.name = 'hello-world'\n"
         buildFile = testProjectDir.newFile('build.gradle')
+        propertiesFile = testProjectDir.newFile('gradle.properties')
+        propertiesFile << "org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME"
     }
 
     GradleRunner gradleRunner(String... arguments) {
@@ -60,6 +63,10 @@ abstract class AbstractGradleFuncTest extends Specification {
         true
     }
 
+    def assertOutputMissing(String givenOutput, String expected) {
+        assert normalized(givenOutput).contains(normalized(expected)) == false
+        true
+    }
     String normalized(String input) {
         String normalizedPathPrefix = testProjectDir.root.canonicalPath.replace('\\', '/')
         return input.readLines()

+ 2 - 0
buildSrc/src/integTest/java/org/elasticsearch/gradle/BuildPluginIT.java

@@ -105,7 +105,9 @@ public class BuildPluginIT extends GradleIntegrationTestCase {
             .withProjectDir(tmpDir.getRoot())
             .withArguments("clean", "hello", "-s", "-i", "--warning-mode=all", "--scan")
             .withPluginClasspath()
+            .forwardOutput()
             .buildAndFail();
+
         assertOutputContains(
             result.getOutput(),
             "repository [" + name + "] on project with path [:] is not using a secure protocol for artifacts on [" + url + "]"

+ 1 - 1
buildSrc/src/integTest/java/org/elasticsearch/gradle/precommit/TestingConventionsTasksIT.java

@@ -62,7 +62,7 @@ public class TestingConventionsTasksIT extends GradleIntegrationTestCase {
             "  * org.elasticsearch.gradle.testkit.LooksLikeATestWithoutNamingConvention2",
             "  * org.elasticsearch.gradle.testkit.LooksLikeATestWithoutNamingConvention3"
         );
-        assertOutputDoesNotContain(result.getOutput(), "LooksLikeTestsButAbstract");
+        assertOutputMissing(result.getOutput(), "LooksLikeTestsButAbstract");
     }
 
     public void testNoEmptyTasks() {

+ 3 - 3
buildSrc/src/integTest/java/org/elasticsearch/gradle/precommit/ThirdPartyAuditTaskIT.java

@@ -74,7 +74,7 @@ public class ThirdPartyAuditTaskIT extends GradleIntegrationTestCase {
 
         assertTaskFailed(result, ":absurd");
         assertOutputContains(result.getOutput(), "Classes with violations:", "  * TestingIO", "> Audit of third party dependencies failed");
-        assertOutputDoesNotContain(result.getOutput(), "Missing classes:");
+        assertOutputMissing(result.getOutput(), "Missing classes:");
         assertNoDeprecationWarning(result);
     }
 
@@ -96,7 +96,7 @@ public class ThirdPartyAuditTaskIT extends GradleIntegrationTestCase {
             "  * org.apache.logging.log4j.LogManager",
             "> Audit of third party dependencies failed"
         );
-        assertOutputDoesNotContain(result.getOutput(), "Classes with violations:");
+        assertOutputMissing(result.getOutput(), "Classes with violations:");
         assertNoDeprecationWarning(result);
     }
 
@@ -118,7 +118,7 @@ public class ThirdPartyAuditTaskIT extends GradleIntegrationTestCase {
             "   Jar Hell with the JDK:",
             "    * java.lang.String"
         );
-        assertOutputDoesNotContain(result.getOutput(), "Classes with violations:");
+        assertOutputMissing(result.getOutput(), "Classes with violations:");
         assertNoDeprecationWarning(result);
     }
 

+ 4 - 1
buildSrc/src/integTest/resources/org/elasticsearch/gradle/internal/fake_git/remote/gradle.properties

@@ -19,4 +19,7 @@
 
 # forcing to use TLS1.2 to avoid failure in vault
 # see https://github.com/hashicorp/vault/issues/8750#issuecomment-631236121
-systemProp.jdk.tls.client.protocols=TLSv1.2
+systemProp.jdk.tls.client.protocols=TLSv1.2
+
+# java homes resolved by environment variables
+org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME

+ 46 - 54
buildSrc/src/main/java/org/elasticsearch/gradle/info/GlobalBuildInfoPlugin.java

@@ -28,12 +28,12 @@ import org.gradle.api.Plugin;
 import org.gradle.api.Project;
 import org.gradle.api.logging.Logger;
 import org.gradle.api.logging.Logging;
-import org.gradle.api.model.ObjectFactory;
-import org.gradle.api.provider.Provider;
 import org.gradle.api.provider.ProviderFactory;
 import org.gradle.internal.jvm.Jvm;
-import org.gradle.jvm.toolchain.JavaInstallation;
-import org.gradle.jvm.toolchain.JavaInstallationRegistry;
+import org.gradle.internal.jvm.inspection.JvmInstallationMetadata;
+import org.gradle.internal.jvm.inspection.JvmMetadataDetector;
+import org.gradle.jvm.toolchain.internal.InstallationLocation;
+import org.gradle.jvm.toolchain.internal.SharedJavaInstallationRegistry;
 import org.gradle.util.GradleVersion;
 
 import javax.inject.Inject;
@@ -50,7 +50,6 @@ import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -68,14 +67,18 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
     private static final String DEFAULT_VERSION_JAVA_FILE_PATH = "server/src/main/java/org/elasticsearch/Version.java";
     private static Integer _defaultParallel = null;
 
-    private final JavaInstallationRegistry javaInstallationRegistry;
-    private final ObjectFactory objects;
+    private final SharedJavaInstallationRegistry javaInstallationRegistry;
+    private final JvmMetadataDetector metadataDetector;
     private final ProviderFactory providers;
 
     @Inject
-    public GlobalBuildInfoPlugin(JavaInstallationRegistry javaInstallationRegistry, ObjectFactory objects, ProviderFactory providers) {
+    public GlobalBuildInfoPlugin(
+        SharedJavaInstallationRegistry javaInstallationRegistry,
+        JvmMetadataDetector metadataDetector,
+        ProviderFactory providers
+    ) {
         this.javaInstallationRegistry = javaInstallationRegistry;
-        this.objects = objects;
+        this.metadataDetector = metadataDetector;
         this.providers = providers;
     }
 
@@ -105,8 +108,8 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
             params.setRuntimeJavaHome(runtimeJavaHome);
             params.setRuntimeJavaVersion(determineJavaVersion("runtime java.home", runtimeJavaHome, minimumRuntimeVersion));
             params.setIsRutimeJavaHomeSet(Jvm.current().getJavaHome().equals(runtimeJavaHome) == false);
-            params.setRuntimeJavaDetails(getJavaInstallation(runtimeJavaHome).getImplementationName());
-            params.setJavaVersions(getAvailableJavaVersions(minimumCompilerVersion));
+            params.setRuntimeJavaDetails(getJavaInstallation(runtimeJavaHome).getDisplayName());
+            params.setJavaVersions(getAvailableJavaVersions());
             params.setMinimumCompilerVersion(minimumCompilerVersion);
             params.setMinimumRuntimeVersion(minimumRuntimeVersion);
             params.setGradleJavaVersion(Jvm.current().getJavaVersion());
@@ -146,20 +149,22 @@ 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();
-        final String gradleJvmDetails = getJavaInstallation(gradleJvm.getJavaHome()).getImplementationName();
-
+        JvmInstallationMetadata gradleJvmMetadata = metadataDetector.getMetadata(gradleJvm.getJavaHome());
+        final String gradleJvmVendorDetails = gradleJvmMetadata.getVendor().getDisplayName();
         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()) {
-            String runtimeJvmDetails = getJavaInstallation(BuildParams.getRuntimeJavaHome()).getImplementationName();
-            LOGGER.quiet("  Runtime JDK Version   : " + BuildParams.getRuntimeJavaVersion() + " (" + runtimeJvmDetails + ")");
+            final String runtimeJvmVendorDetails = metadataDetector.getMetadata(BuildParams.getRuntimeJavaHome())
+                .getVendor()
+                .getDisplayName();
+            LOGGER.quiet("  Runtime JDK Version   : " + BuildParams.getRuntimeJavaVersion() + " (" + runtimeJvmVendorDetails + ")");
             LOGGER.quiet("  Runtime java.home     : " + BuildParams.getRuntimeJavaHome());
-            LOGGER.quiet("  Gradle JDK Version    : " + gradleJvm.getJavaVersion() + " (" + gradleJvmDetails + ")");
+            LOGGER.quiet("  Gradle JDK Version    : " + gradleJvm.getJavaVersion() + " (" + gradleJvmVendorDetails + ")");
             LOGGER.quiet("  Gradle java.home      : " + gradleJvm.getJavaHome());
         } else {
-            LOGGER.quiet("  JDK Version           : " + gradleJvm.getJavaVersion() + " (" + gradleJvmDetails + ")");
+            LOGGER.quiet("  JDK Version           : " + gradleJvm.getJavaVersion() + " (" + gradleJvmVendorDetails + ")");
             LOGGER.quiet("  JAVA_HOME             : " + gradleJvm.getJavaHome());
         }
         LOGGER.quiet("  Random Testing Seed   : " + BuildParams.getTestSeed());
@@ -168,8 +173,8 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
     }
 
     private JavaVersion determineJavaVersion(String description, File javaHome, JavaVersion requiredVersion) {
-        JavaInstallation installation = getJavaInstallation(javaHome);
-        JavaVersion actualVersion = installation.getJavaVersion();
+        InstallationLocation installation = getJavaInstallation(javaHome);
+        JavaVersion actualVersion = metadataDetector.getMetadata(installation.getLocation()).getLanguageVersion();
         if (actualVersion.isCompatibleWith(requiredVersion) == false) {
             throwInvalidJavaHomeException(
                 description,
@@ -182,46 +187,33 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
         return actualVersion;
     }
 
-    private JavaInstallation getJavaInstallation(File javaHome) {
-        JavaInstallation installation;
-        if (isCurrentJavaHome(javaHome)) {
-            installation = javaInstallationRegistry.getInstallationForCurrentVirtualMachine().get();
-        } else {
-            installation = javaInstallationRegistry.installationForDirectory(objects.directoryProperty().fileValue(javaHome)).get();
-        }
-
-        return installation;
+    private InstallationLocation getJavaInstallation(File javaHome) {
+        return javaInstallationRegistry.listInstallations()
+            .stream()
+            .filter(installationLocation -> isSameFile(javaHome, installationLocation))
+            .findFirst()
+            .get();
     }
 
-    private List<JavaHome> getAvailableJavaVersions(JavaVersion minimumCompilerVersion) {
-        final List<JavaHome> javaVersions = new ArrayList<>();
-        for (int v = 8; v <= Integer.parseInt(minimumCompilerVersion.getMajorVersion()); v++) {
-            int version = v;
-            String javaHomeEnvVarName = getJavaHomeEnvVarName(Integer.toString(version));
-            if (System.getenv(javaHomeEnvVarName) != null) {
-                File javaHomeDirectory = new File(findJavaHome(Integer.toString(version)));
-                Provider<JavaInstallation> javaInstallationProvider = javaInstallationRegistry.installationForDirectory(
-                    objects.directoryProperty().fileValue(javaHomeDirectory)
-                );
-                JavaHome javaHome = JavaHome.of(version, providers.provider(() -> {
-                    int actualVersion = Integer.parseInt(javaInstallationProvider.get().getJavaVersion().getMajorVersion());
-                    if (actualVersion != version) {
-                        throwInvalidJavaHomeException("env variable " + javaHomeEnvVarName, javaHomeDirectory, version, actualVersion);
-                    }
-                    return javaHomeDirectory;
-                }));
-                javaVersions.add(javaHome);
-            }
+    private boolean isSameFile(File javaHome, InstallationLocation installationLocation) {
+        try {
+            return Files.isSameFile(installationLocation.getLocation().toPath(), javaHome.toPath());
+        } catch (IOException ioException) {
+            throw new UncheckedIOException(ioException);
         }
-        return javaVersions;
     }
 
-    private static boolean isCurrentJavaHome(File javaHome) {
-        try {
-            return Files.isSameFile(javaHome.toPath(), Jvm.current().getJavaHome().toPath());
-        } catch (IOException e) {
-            throw new UncheckedIOException(e);
-        }
+    /**
+     * We resolve all available java versions using auto detected by gradles tool chain
+     * To make transition more reliable we only take env var provided installations into account for now
+     */
+    private List<JavaHome> getAvailableJavaVersions() {
+        return javaInstallationRegistry.listInstallations().stream().map(installationLocation -> {
+            File installationDir = installationLocation.getLocation();
+            JvmInstallationMetadata metadata = metadataDetector.getMetadata(installationDir);
+            int actualVersion = Integer.parseInt(metadata.getLanguageVersion().getMajorVersion());
+            return JavaHome.of(actualVersion, providers.provider(() -> installationDir));
+        }).collect(Collectors.toList());
     }
 
     private static String getTestSeed() {

+ 3 - 0
buildSrc/src/main/java/org/elasticsearch/gradle/precommit/JarHellPrecommitPlugin.java

@@ -32,6 +32,9 @@ public class JarHellPrecommitPlugin extends PrecommitPlugin {
     public TaskProvider<? extends Task> createTask(Project project) {
         Configuration jarHellConfig = project.getConfigurations().create("jarHell");
         if (BuildParams.isInternal() && project.getPath().equals(":libs:elasticsearch-core") == false) {
+            // ideally we would configure this as a default dependency. But Default dependencies do not work correctly
+            // with gradle project dependencies as they're resolved to late in the build and don't setup according task
+            // dependencies properly
             project.getDependencies().add("jarHell", project.project(":libs:elasticsearch-core"));
         }
         TaskProvider<JarHellTask> jarHell = project.getTasks().register("jarHell", JarHellTask.class);

+ 0 - 3
buildSrc/src/main/java/org/elasticsearch/gradle/transform/SymbolicLinkPreservingUntarTransform.java

@@ -22,7 +22,6 @@ package org.elasticsearch.gradle.transform;
 import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
 import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
 import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
-import org.gradle.api.logging.Logging;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -40,8 +39,6 @@ public abstract class SymbolicLinkPreservingUntarTransform implements UnpackTran
     private static final Path CURRENT_DIR_PATH = Paths.get(".");
 
     public void unpack(File tarFile, File targetDir) throws IOException {
-        Logging.getLogger(SymbolicLinkPreservingUntarTransform.class)
-            .info("Unpacking " + tarFile.getName() + " using " + SymbolicLinkPreservingUntarTransform.class.getSimpleName() + ".");
         Function<String, Path> pathModifier = pathResolver();
 
         TarArchiveInputStream tar = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(tarFile)));

+ 3 - 0
buildSrc/src/main/java/org/elasticsearch/gradle/transform/UnpackTransform.java

@@ -24,6 +24,7 @@ import org.gradle.api.artifacts.transform.TransformAction;
 import org.gradle.api.artifacts.transform.TransformOutputs;
 import org.gradle.api.artifacts.transform.TransformParameters;
 import org.gradle.api.file.FileSystemLocation;
+import org.gradle.api.logging.Logging;
 import org.gradle.api.provider.Provider;
 import org.gradle.api.tasks.Input;
 import org.gradle.api.tasks.Optional;
@@ -56,6 +57,8 @@ public interface UnpackTransform extends TransformAction<UnpackTransform.Paramet
         File archiveFile = getArchiveFile().get().getAsFile();
         File extractedDir = outputs.dir(archiveFile.getName());
         try {
+            Logging.getLogger(UnpackTransform.class)
+                .info("Unpacking " + archiveFile.getName() + " using " + getClass().getSimpleName() + ".");
             unpack(archiveFile, extractedDir);
         } catch (IOException e) {
             throw UncheckedException.throwAsUncheckedException(e);

+ 1 - 1
buildSrc/src/main/resources/minimumGradleVersion

@@ -1 +1 @@
-6.6.1
+6.8

+ 0 - 73
buildSrc/src/test/java/org/elasticsearch/gradle/plugin/PluginBuildPluginTests.java

@@ -1,73 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you 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
- *
- *    http://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.gradle.plugin;
-
-import org.elasticsearch.gradle.BwcVersions;
-import org.elasticsearch.gradle.test.GradleUnitTestCase;
-import org.gradle.api.Project;
-import org.gradle.api.Task;
-import org.gradle.api.internal.project.ProjectInternal;
-import org.gradle.testfixtures.ProjectBuilder;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.mockito.Mockito;
-
-import java.util.stream.Collectors;
-
-public class PluginBuildPluginTests extends GradleUnitTestCase {
-
-    private Project project;
-
-    @Before
-    public void setUp() throws Exception {
-        project = ProjectBuilder.builder().withName(getClass().getName()).build();
-    }
-
-    public void testApply() {
-        // FIXME: distribution download plugin doesn't support running externally
-        project.getExtensions().getExtraProperties().set("bwcVersions", Mockito.mock(BwcVersions.class));
-        project.getPlugins().apply(PluginBuildPlugin.class);
-
-        assertNotNull(
-            "plugin extension created with the right name",
-            project.getExtensions().findByName(PluginBuildPlugin.PLUGIN_EXTENSION_NAME)
-        );
-        assertNotNull("plugin extensions has the right type", project.getExtensions().findByType(PluginPropertiesExtension.class));
-
-        assertNull("plugin should not create the integTest task", project.getTasks().findByName("integTest"));
-    }
-
-    @Ignore("https://github.com/elastic/elasticsearch/issues/47123")
-    public void testApplyWithAfterEvaluate() {
-        project.getExtensions().getExtraProperties().set("bwcVersions", Mockito.mock(BwcVersions.class));
-        project.getPlugins().apply(PluginBuildPlugin.class);
-        PluginPropertiesExtension extension = project.getExtensions().getByType(PluginPropertiesExtension.class);
-        extension.setNoticeFile(project.file("test.notice"));
-        extension.setLicenseFile(project.file("test.license"));
-        extension.setDescription("just a test");
-        extension.setClassname(getClass().getName());
-
-        ((ProjectInternal) project).evaluate();
-
-        assertNotNull(
-            "Task to generate notice not created: " + project.getTasks().stream().map(Task::getPath).collect(Collectors.joining(", ")),
-            project.getTasks().findByName("generateNotice")
-        );
-    }
-}

+ 4 - 4
buildSrc/src/testFixtures/java/org/elasticsearch/gradle/test/GradleIntegrationTestCase.java

@@ -99,13 +99,13 @@ public abstract class GradleIntegrationTestCase extends GradleUnitTestCase {
         assertThat("Expected the following line in output:\n\n" + line + "\n\nOutput is:\n" + output, output, containsString(line));
     }
 
-    protected void assertOutputDoesNotContain(String output, String line) {
+    protected void assertOutputMissing(String output, String line) {
         assertFalse("Expected the following line not to be in output:\n\n" + line + "\n\nOutput is:\n" + output, output.contains(line));
     }
 
-    protected void assertOutputDoesNotContain(String output, String... lines) {
+    protected void assertOutputMissing(String output, String... lines) {
         for (String line : lines) {
-            assertOutputDoesNotContain(line);
+            assertOutputMissing(line);
         }
     }
 
@@ -167,7 +167,7 @@ public abstract class GradleIntegrationTestCase extends GradleUnitTestCase {
     }
 
     protected void assertNoDeprecationWarning(BuildResult result) {
-        assertOutputDoesNotContain(result.getOutput(), "Deprecated Gradle features were used in this build");
+        assertOutputMissing(result.getOutput(), "Deprecated Gradle features were used in this build");
     }
 
     protected void assertBuildFileExists(BuildResult result, String projectName, String path) {

+ 22 - 0
buildSrc/src/testKit/elasticsearch-build-resources/gradle.properties

@@ -0,0 +1,22 @@
+#
+# Licensed to Elasticsearch under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Elasticsearch licenses this file to you 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
+#
+#     http://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.
+#
+
+# java homes resolved by environment variables
+org.gradle.java.installations.auto-detect=false
+org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME

+ 22 - 0
buildSrc/src/testKit/elasticsearch.build/gradle.properties

@@ -0,0 +1,22 @@
+#
+# Licensed to Elasticsearch under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Elasticsearch licenses this file to you 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
+#
+#     http://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.
+#
+
+# java homes resolved by environment variables
+org.gradle.java.installations.auto-detect=false
+org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME

+ 22 - 0
buildSrc/src/testKit/reaper/gradle.properties

@@ -0,0 +1,22 @@
+#
+# Licensed to Elasticsearch under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Elasticsearch licenses this file to you 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
+#
+#     http://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.
+#
+
+# java homes resolved by environment variables
+org.gradle.java.installations.auto-detect=false
+org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME

+ 22 - 0
buildSrc/src/testKit/thirdPartyAudit/gradle.properties

@@ -0,0 +1,22 @@
+#
+# Licensed to Elasticsearch under one or more contributor
+# license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright
+# ownership. Elasticsearch licenses this file to you 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
+#
+#     http://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.
+#
+
+# java homes resolved by environment variables
+org.gradle.java.installations.auto-detect=false
+org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME

+ 4 - 0
gradle.properties

@@ -12,3 +12,7 @@ systemProp.org.gradle.warning.mode=fail
 # forcing to use TLS1.2 to avoid failure in vault
 # see https://github.com/hashicorp/vault/issues/8750#issuecomment-631236121
 systemProp.jdk.tls.client.protocols=TLSv1.2
+
+# java homes resolved by environment variables
+org.gradle.java.installations.auto-detect=false
+org.gradle.java.installations.fromEnv=JAVA_HOME,RUNTIME_JAVA_HOME,JAVA15_HOME,JAVA14_HOME,JAVA13_HOME,JAVA12_HOME,JAVA11_HOME,JAVA8_HOME

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

@@ -1,6 +1,6 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionSha256Sum=11657af6356b7587bfb37287b5992e94a9686d5c8a0a1b60b87b9928a2decde5
+distributionSha256Sum=a7ca23b3ccf265680f2bfd35f1f00b1424f4466292c7337c85d46c9641b3f053