Skip to content

Commit c6329ce

Browse files
authored
Update Gradle wrapper to 8.8 (#2232)
* Update Gradle wrapper to 8.8 * fix 8.8 deprecations * Fix deprecation warning from shadow plugin
1 parent f1cb6b2 commit c6329ce

File tree

8 files changed

+66
-14
lines changed

8 files changed

+66
-14
lines changed

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/BuildPlugin.groovy

+11-4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ import javax.inject.Inject
7070

7171
import static org.elasticsearch.hadoop.gradle.scala.SparkVariantPlugin.SparkVariantPluginExtension
7272
import static org.elasticsearch.hadoop.gradle.scala.SparkVariantPlugin.SparkVariant
73+
import org.gradle.api.artifacts.ResolvableDependencies;
74+
import org.gradle.api.artifacts.component.ComponentIdentifier;
75+
import org.gradle.api.artifacts.result.ResolvedComponentResult;
76+
import org.gradle.api.artifacts.result.ResolvedDependencyResult;
77+
import org.gradle.api.file.FileCollection;
78+
import org.gradle.api.specs.AndSpec;
79+
import org.gradle.api.specs.Spec;
80+
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
81+
import java.util.stream.Collectors;
7382

7483
class BuildPlugin implements Plugin<Project> {
7584

@@ -845,10 +854,8 @@ class BuildPlugin implements Plugin<Project> {
845854
precommitTasks.add(licenseHeaders)
846855

847856
if (!project.path.startsWith(":qa")) {
848-
TaskProvider<DependencyLicensesTask> dependencyLicenses = project.tasks.register('dependencyLicenses', DependencyLicensesTask.class) {
849-
dependencies = project.configurations.runtimeClasspath.fileCollection {
850-
!(it instanceof ProjectDependency)
851-
}
857+
TaskProvider<DependencyLicensesTask> dependencyLicenses = project.tasks.register('dependencyLicenses', DependencyLicensesTask.class) {
858+
dependencies = project.configurations.runtimeClasspath
852859
mapping from: /hadoop-.*/, to: 'hadoop'
853860
mapping from: /hive-.*/, to: 'hive'
854861
mapping from: /jackson-.*/, to: 'jackson'

buildSrc/src/main/java/org/elasticsearch/hadoop/gradle/buildtools/DependencyLicensesTask.java

+33-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
import java.util.regex.Matcher;
5252
import java.util.regex.Pattern;
5353
import java.util.stream.Collectors;
54+
import org.gradle.api.artifacts.ResolvableDependencies;
55+
import org.gradle.api.artifacts.component.ComponentIdentifier;
56+
import org.gradle.api.artifacts.result.ResolvedComponentResult;
57+
import org.gradle.api.artifacts.result.ResolvedDependencyResult;
58+
import org.gradle.api.file.FileCollection;
59+
import org.gradle.api.specs.AndSpec;
60+
import org.gradle.api.specs.Spec;
61+
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
62+
import java.util.stream.Collectors;
63+
import org.gradle.api.artifacts.Configuration;
5464

5565
/**
5666
* A task to check licenses for dependencies.
@@ -94,7 +104,7 @@
94104
* for the dependency. This artifact will be redistributed by us with the release to
95105
* comply with the license terms.
96106
*/
97-
public class DependencyLicensesTask extends DefaultTask {
107+
public abstract class DependencyLicensesTask extends DefaultTask {
98108

99109
private final Pattern regex = Pattern.compile("-v?\\d+.*");
100110

@@ -148,7 +158,28 @@ public FileCollection getDependencies() {
148158
return dependencies;
149159
}
150160

151-
public void setDependencies(FileCollection dependencies) {
161+
public void setDependencies(Configuration configuration) {
162+
ResolvableDependencies incoming = configuration.getIncoming();
163+
dependencies = incoming.artifactView(viewConfiguration -> {
164+
Set<ComponentIdentifier> firstLevelDependencyComponents = incoming.getResolutionResult()
165+
.getRootComponent()
166+
.map(rootComponent -> rootComponent.getDependencies()
167+
.stream()
168+
.filter(dependency -> dependency instanceof ResolvedDependencyResult)
169+
.map(dependency -> (ResolvedDependencyResult) dependency)
170+
.filter(dependency -> dependency.getSelected() instanceof ResolvedComponentResult)
171+
.map(dependency -> dependency.getSelected().getId())
172+
.collect(Collectors.toSet())
173+
).get();
174+
Spec<ComponentIdentifier> componentFilter = (identifier -> identifier instanceof ModuleComponentIdentifier
175+
&& ((ModuleComponentIdentifier) identifier).getGroup().startsWith("org.elasticsearch") == false);
176+
Spec<ComponentIdentifier> firstLevelFilter = (identifier -> firstLevelDependencyComponents.contains(identifier));
177+
viewConfiguration.componentFilter(
178+
new AndSpec<>(firstLevelFilter, componentFilter)
179+
);
180+
}).getFiles();
181+
182+
152183
this.dependencies = dependencies;
153184
}
154185

buildSrc/src/main/java/org/elasticsearch/hadoop/gradle/buildtools/info/GlobalBuildInfoPlugin.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private List<JavaHome> getAvailableJavaVersions() {
200200
private Stream<InstallationLocation> getAvailableJavaInstallationLocationSteam() {
201201
return Stream.concat(
202202
javaInstallationRegistry.toolchains().stream().map(metadata -> metadata.location),
203-
Stream.of(new InstallationLocation(Jvm.current().getJavaHome(), "Current JVM"))
203+
Stream.of(InstallationLocation.userDefined(Jvm.current().getJavaHome(), "Current JVM"))
204204
);
205205
}
206206

dist/build.gradle

+1-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,5 @@ task generateDependenciesReport(type: ConcatFilesTask) { concatDepsTask ->
195195
}
196196

197197
project.tasks.named('dependencyLicenses', DependencyLicensesTask) {
198-
it.dependencies = project.configurations.licenseChecks.fileCollection {
199-
!(it instanceof ProjectDependency)
200-
}
198+
it.dependencies = project.configurations.licenseChecks
201199
}

gradle/wrapper/gradle-wrapper.jar

-9 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=9631d53cf3e74bfa726893aee1f8994fee4e060c401335946dba2156f440f24c
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
3+
distributionSha256Sum=a4b4158601f8636cdeeab09bd76afb640030bb5b144aafe261a5e8af027dc612
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

gradlew

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.

thirdparty/build.gradle

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
import org.elasticsearch.hadoop.gradle.BuildPlugin
22

3+
4+
5+
buildscript {
6+
repositories {
7+
maven {
8+
url 'https://jitpack.io'
9+
}
10+
mavenCentral()
11+
}
12+
dependencies {
13+
classpath 'com.github.breskeby:shadow:3b035f2'
14+
}
15+
}
16+
317
plugins {
4-
id 'com.github.johnrengelman.shadow'
518
id 'es.hadoop.build'
619
}
720

21+
apply plugin: 'com.github.johnrengelman.shadow'
22+
23+
824
description = "Elasticsearch Hadoop Shaded Third-Party Libraries"
925

1026
configurations {

0 commit comments

Comments
 (0)