Skip to content

Commit

Permalink
Update Gradle wrapper to 8.0.2 (elastic#92751)
Browse files Browse the repository at this point in the history
- Remove custom checksum build logic in wrapper task
- Adjust jdk home handling adjusting the change in behaviour in gradle. Requires providing canonical paths for provisioned jdk homes.
- Fix test by add workaround to bug in configuration cache
  • Loading branch information
breskeby authored Mar 9, 2023
1 parent 8e4f1da commit 9ce5bae
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 40 deletions.
4 changes: 2 additions & 2 deletions build-tools-internal/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionSha256Sum=47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=518a863631feb7452b8f1b3dc2aaee5f388355cc3421bbd0275fbeadd77e84b2
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ class ElasticsearchJavaModulePathPluginFuncTest extends AbstractJavaGradleFuncTe
public static final String ES_VERSION = VersionProperties.getElasticsearch()

public static final String COMPILE_JAVA_CONFIG = """
def sep = org.elasticsearch.gradle.OS.current() == org.elasticsearch.gradle.OS.WINDOWS ? ':' : ';'
tasks.named('compileJava').configure {
doLast {
def sep = org.elasticsearch.gradle.OS.current() == org.elasticsearch.gradle.OS.WINDOWS ? ':' : ';'
println "COMPILE_JAVA_COMPILER_ARGS " + options.allCompilerArgs.join(sep)
println "COMPILE_JAVA_CLASSPATH " + classpath.asPath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import org.gradle.testkit.runner.TaskOutcome

class ElasticsearchTestBasePluginFuncTest extends AbstractGradleFuncTest {

def setup() {
// see https://github.com/gradle/gradle/issues/24172
configurationCacheCompatible = false
}

def "can configure nonInputProperties for test tasks"() {
given:
file("src/test/java/acme/SomeTests.java").text = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.gradle.testkit.runner.TaskOutcome
class InternalBwcGitPluginFuncTest extends AbstractGitAwareGradleFuncTest {

def setup() {
configurationCacheCompatible = false
internalBuild()
buildFile << """
import org.elasticsearch.gradle.Version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
private static final String OPEN_JDK_VERSION = "12.0.1+99@123456789123456789123456789abcde"
private static final Pattern JDK_HOME_LOGLINE = Pattern.compile("JDK HOME: (.*)")

def setup() {
configurationCacheCompatible = false
}

@Unroll
def "jdk #jdkVendor for #platform#suffix are downloaded and extracted"() {
given:
Expand All @@ -54,10 +58,11 @@ class JdkDownloadPluginFuncTest extends AbstractGradleFuncTest {
}
}
def theJdks = jdks
tasks.register("getJdk") {
dependsOn jdks.myJdk
doLast {
println "JDK HOME: " + jdks.myJdk
println "JDK HOME: " + theJdks.myJdk
}
}
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
def setup() {
// required for JarHell to work
subProject(":libs:elasticsearch-core") << "apply plugin:'java'"

configurationCacheCompatible = false
}

def "artifacts and tweaked pom is published"() {
given:
buildFile << """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ public void execute(Task task) {
var withShadowPlugin = project1.getPlugins().hasPlugin(ShadowPlugin.class);
var compileClasspath = project.getConfigurations().getByName("compileClasspath");

var copiedCompileClasspath = project.getConfigurations().create("copiedCompileClasspath");
copiedCompileClasspath.extendsFrom(compileClasspath);
if (withShadowPlugin) {
var shadowConfiguration = project.getConfigurations().getByName("shadow");
var shadowedDependencies = shadowConfiguration.getAllDependencies();
var nonShadowedCompileClasspath = compileClasspath.copyRecursive(
var nonShadowedCompileClasspath = copiedCompileClasspath.copyRecursive(
dependency -> shadowedDependencies.contains(dependency) == false
);
configureJavadocForConfiguration(project, false, nonShadowedCompileClasspath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.gradle.internal;

import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.api.artifacts.dsl.DependencyHandler;
import org.gradle.api.plugins.BasePluginExtension;
Expand Down Expand Up @@ -40,9 +41,18 @@ public void registerTestArtifactFromSourceSet(SourceSet sourceSet) {

DependencyHandler dependencies = project.getDependencies();
project.getPlugins().withType(JavaPlugin.class, javaPlugin -> {
Configuration apiElements = project.getConfigurations().getByName(sourceSet.getApiElementsConfigurationName());
Configuration apiElementsTestArtifacts = project.getConfigurations()
.create(sourceSet.getApiConfigurationName() + "TestArtifacts");
apiElements.extendsFrom(apiElementsTestArtifacts);
Dependency projectDependency = dependencies.create(project);
dependencies.add(sourceSet.getApiElementsConfigurationName(), projectDependency);
dependencies.add(sourceSet.getRuntimeElementsConfigurationName(), projectDependency);
dependencies.add(apiElementsTestArtifacts.getName(), projectDependency);

Configuration runtimeElements = project.getConfigurations().getByName(sourceSet.getRuntimeElementsConfigurationName());
Configuration runtimeElementsTestArtifacts = project.getConfigurations()
.create(sourceSet.getRuntimeElementsConfigurationName() + "TestArtifacts");
runtimeElements.extendsFrom(runtimeElementsTestArtifacts);
dependencies.add(runtimeElementsTestArtifacts.getName(), projectDependency);
});
// PolicyUtil doesn't handle classifier notation well probably.
// Instead of fixing PoliceUtil we stick to the pattern of changing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.gradle.api.tasks.TaskDependency;

import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -152,7 +153,11 @@ public Object getBinJavaPath() {
return new Object() {
@Override
public String toString() {
return getHomeRoot() + getPlatformBinPath();
try {
return new File(getHomeRoot() + getPlatformBinPath()).getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.gradle.jvm.toolchain.JavaToolchainSpec;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.time.ZonedDateTime;
import java.util.Arrays;
Expand Down Expand Up @@ -177,7 +178,11 @@ public void reset() {
}

public void setRuntimeJavaHome(File runtimeJavaHome) {
BuildParams.runtimeJavaHome = requireNonNull(runtimeJavaHome);
try {
BuildParams.runtimeJavaHome = requireNonNull(runtimeJavaHome).getCanonicalFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public void setIsRuntimeJavaHomeSet(boolean isRutimeJavaHomeSet) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.6.1
8.0.2
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.Project;
import org.gradle.testfixtures.ProjectBuilder;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertThrows;

public class JdkDownloadPluginTests {
private static Project rootProject;

@BeforeClass
public static void setupRoot() {
rootProject = ProjectBuilder.builder().build();
}

@Test
public void testMissingVendor() {
Expand Down Expand Up @@ -134,7 +127,7 @@ private void createJdk(Project project, String name, String vendor, String versi
}

private Project createProject() {
Project project = ProjectBuilder.builder().withParent(rootProject).build();
Project project = ProjectBuilder.builder().withParent(ProjectBuilder.builder().build()).build();
project.getPlugins().apply("elasticsearch.jdk-download");
return project;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@
package org.elasticsearch.gradle.testclusters;

import org.elasticsearch.gradle.FileSystemOperationsAware;
import org.elasticsearch.gradle.util.GradleUtils;
import org.gradle.api.Task;
import org.gradle.api.provider.Provider;
import org.gradle.api.services.internal.BuildServiceProvider;
import org.gradle.api.services.internal.BuildServiceRegistryInternal;
import org.gradle.api.specs.NotSpec;
import org.gradle.api.specs.Spec;
Expand Down Expand Up @@ -85,9 +84,8 @@ public Collection<ElasticsearchCluster> getClusters() {
public List<ResourceLock> getSharedResources() {
List<ResourceLock> locks = new ArrayList<>(super.getSharedResources());
BuildServiceRegistryInternal serviceRegistry = getServices().get(BuildServiceRegistryInternal.class);
Provider<TestClustersThrottle> throttleProvider = GradleUtils.getBuildService(serviceRegistry, THROTTLE_SERVICE_NAME);
SharedResource resource = serviceRegistry.forService(throttleProvider);

BuildServiceProvider<?, ?> serviceProvider = serviceRegistry.consume(THROTTLE_SERVICE_NAME, TestClustersThrottle.class);
SharedResource resource = serviceRegistry.forService(serviceProvider);
int nodeCount = clusters.stream().mapToInt(cluster -> cluster.getNodes().size()).sum();
if (nodeCount > 0) {
for (int i = 0; i < Math.min(nodeCount, resource.getMaxUsages()); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,9 @@ public BuildResult build() throws InvalidRunnerConfigurationException, Unexpecte
public BuildResult buildAndFail() throws InvalidRunnerConfigurationException, UnexpectedBuildSuccess {
return delegate.buildAndFail();
}

@Override
public BuildResult run() throws InvalidRunnerConfigurationException {
return delegate.run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,9 @@ public BuildResult build() throws InvalidRunnerConfigurationException, Unexpecte
public BuildResult buildAndFail() throws InvalidRunnerConfigurationException, UnexpectedBuildSuccess {
return delegate.buildAndFail();
}

@Override
public BuildResult run() throws InvalidRunnerConfigurationException {
return delegate.run();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ public BuildResult buildAndFail() throws InvalidRunnerConfigurationException, Un
return new NormalizedBuildResult(delegate.buildAndFail());
}

@Override
public BuildResult run() throws InvalidRunnerConfigurationException {
return new NormalizedBuildResult(delegate.run());
}

private class NormalizedBuildResult implements BuildResult {
private BuildResult delegate;
private String normalizedString;
Expand Down
7 changes: 0 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,6 @@ tasks.register("branchConsistency") {
tasks.named("wrapper").configure {
distributionType = 'ALL'
doLast {
final DistributionLocator locator = new DistributionLocator()
final GradleVersion version = GradleVersion.version(wrapper.gradleVersion)
final URI distributionUri = locator.getDistributionFor(version, wrapper.distributionType.name().toLowerCase(Locale.ENGLISH))
final URI sha256Uri = new URI(distributionUri.toString() + ".sha256")
final String sha256Sum = new String(sha256Uri.toURL().bytes)
wrapper.getPropertiesFile() << "distributionSha256Sum=${sha256Sum}\n"
println "Added checksum to wrapper properties"
// copy wrapper properties file to build-tools-internal to allow seamless idea integration
def file = new File("build-tools-internal/gradle/wrapper/gradle-wrapper.properties")
Files.copy(wrapper.getPropertiesFile().toPath(), file.toPath(), REPLACE_EXISTING)
Expand Down
2 changes: 1 addition & 1 deletion distribution/packages/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import java.util.regex.Pattern
*/

plugins {
id "nebula.ospackage-base" version "9.1.1"
id "com.netflix.nebula.ospackage-base" version "11.0.0"
}

['deb', 'rpm'].each { type ->
Expand Down
6 changes: 3 additions & 3 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,9 @@
<sha256 value="d694edd7bae3bc1a8e0dae2f5a22c479ff04d6b9bfcb0ab751a42f02e02d2100" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.netflix.nebula" name="gradle-ospackage-plugin" version="9.1.1">
<artifact name="gradle-ospackage-plugin-9.1.1.jar">
<sha256 value="4ef3d17d706ba8640c951b66c9d41589d508ea81dee104e2fae771e3424636dc" origin="Generated by Gradle"/>
<component group="com.netflix.nebula" name="gradle-ospackage-plugin" version="11.0.0">
<artifact name="gradle-ospackage-plugin-11.0.0.jar">
<sha256 value="d8bd5525b6af61be47ac3790f11604a1549a7791f5f13708bbd517f3791baf94" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="com.netflix.nebula" name="nebula-gradle-interop" version="2.0.0">
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionSha256Sum=47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=518a863631feb7452b8f1b3dc2aaee5f388355cc3421bbd0275fbeadd77e84b2
4 changes: 2 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ 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
# 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
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down
4 changes: 2 additions & 2 deletions plugins/examples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip
distributionSha256Sum=47a5bfed9ef814f90f8debcbbb315e8e7c654109acd224595ea39fca95c5d4da
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=518a863631feb7452b8f1b3dc2aaee5f388355cc3421bbd0275fbeadd77e84b2

0 comments on commit 9ce5bae

Please sign in to comment.