Skip to content

Commit 877acb6

Browse files
authored
Update Gradle wrapper to 9.0.0 (#2438) (#2440)
* Update Gradle wrapper to 9.0.0 * Fix 9.0 incompatibilities * Update shadow plugin (cherry picked from commit 38e813c)
1 parent 2208d0d commit 877acb6

File tree

14 files changed

+60
-46
lines changed

14 files changed

+60
-46
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,8 @@ class BuildPlugin implements Plugin<Project> {
839839

840840
if (!project.path.startsWith(":qa")) {
841841
TaskProvider<DependencyLicensesTask> dependencyLicenses = project.tasks.register('dependencyLicenses', DependencyLicensesTask.class) {
842+
licensesDir = project.file("licenses")
843+
outputMarker = new File(project.getBuildDir(), "dependencyLicense")
842844
dependencies = project.configurations.runtimeClasspath
843845
mapping from: /hadoop-.*/, to: 'hadoop'
844846
mapping from: /hive-.*/, to: 'hive'

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/buildtools/AntFixture.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.apache.tools.ant.taskdefs.condition.Os
2323
import org.gradle.api.GradleException
2424
import org.gradle.api.tasks.Internal
2525
import org.gradle.api.tasks.TaskProvider
26+
import groovy.ant.AntBuilder;
2627

2728
/**
2829
* A fixture for integration tests which runs in a separate process launched by Ant.

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/buildtools/AntFixtureStop.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import org.gradle.api.tasks.Internal
2525

2626
import javax.inject.Inject
2727

28-
class AntFixtureStop extends LoggedExec {
28+
abstract class AntFixtureStop extends LoggedExec {
2929

3030
@Internal
3131
AntFixture fixture

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/buildtools/AntTask.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import org.gradle.api.tasks.TaskAction
3030

3131
import javax.inject.Inject
3232
import java.nio.charset.Charset
33+
import groovy.ant.AntBuilder
3334

3435
/**
3536
* A task which will run ant commands.

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public abstract class DependencyLicensesTask extends DefaultTask {
122122
/**
123123
* The directory to find the license and sha files in.
124124
*/
125-
private File licensesDir = new File(getProject().getProjectDir(), "licenses");
125+
private File licensesDir;
126126

127127
/**
128128
* A map of patterns to prefix, used to find the LICENSE and NOTICE file.
@@ -134,6 +134,13 @@ public abstract class DependencyLicensesTask extends DefaultTask {
134134
*/
135135
private Set<String> ignoreShas = new HashSet<>();
136136

137+
/**
138+
* A marker output directory to allow this task being up-to-date.
139+
* The check logic is exception driven so a failed tasks will not be defined
140+
* by this output but when successful we can safely mark the task as up-to-date.
141+
*/
142+
private File outputMarker;
143+
137144
/**
138145
* Add a mapping from a regex pattern for the jar name, to a prefix to find
139146
* the LICENSE and NOTICE file for that jar.
@@ -257,12 +264,13 @@ public void checkDependencies() throws IOException, NoSuchAlgorithmException {
257264

258265
}
259266

260-
// This is just a marker output folder to allow this task being up-to-date.
261-
// The check logic is exception driven so a failed tasks will not be defined
262-
// by this output but when successful we can safely mark the task as up-to-date.
263267
@OutputDirectory
264268
public File getOutputMarker() {
265-
return new File(getProject().getBuildDir(), "dependencyLicense");
269+
return outputMarker;
270+
}
271+
272+
public void setOutputMarker(File outputMarker) {
273+
this.outputMarker = outputMarker;
266274
}
267275

268276
private void failIfAnyMissing(String item, Boolean exists, String type) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* A wrapper around gradle's Exec task to capture output and log on error.
5151
*/
5252
@SuppressWarnings("unchecked")
53-
public class LoggedExec extends Exec implements FileSystemOperationsAware {
53+
public abstract class LoggedExec extends Exec implements FileSystemOperationsAware {
5454

5555
private static final Logger LOGGER = Logging.getLogger(LoggedExec.class);
5656
private Consumer<Logger> outputLogger;

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.gradle.api.GradleException;
2626
import org.gradle.api.Project;
2727
import org.gradle.api.file.FileTree;
28-
import org.gradle.api.plugins.JavaPluginConvention;
28+
import org.gradle.api.plugins.JavaPluginExtension;
2929
import org.gradle.api.tasks.SourceSet;
3030
import org.gradle.api.tasks.util.PatternFilterable;
3131

@@ -134,7 +134,7 @@ public static FileTree getJavaTestAndMainSourceResources(Project project, Action
134134
* @return An Optional that contains the Java test SourceSet if it exists.
135135
*/
136136
public static Optional<SourceSet> getJavaTestSourceSet(Project project) {
137-
return project.getConvention().findPlugin(JavaPluginConvention.class) == null
137+
return project.getExtensions().findByType(JavaPluginExtension.class) == null
138138
? Optional.empty()
139139
: Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(SourceSet.TEST_SOURCE_SET_NAME));
140140
}
@@ -144,7 +144,7 @@ public static Optional<SourceSet> getJavaTestSourceSet(Project project) {
144144
* @return An Optional that contains the Java main SourceSet if it exists.
145145
*/
146146
public static Optional<SourceSet> getJavaMainSourceSet(Project project) {
147-
return project.getConvention().findPlugin(JavaPluginConvention.class) == null
147+
return project.getExtensions().findByType(JavaPluginExtension.class) == null
148148
? Optional.empty()
149149
: Optional.ofNullable(GradleUtils.getJavaSourceSets(project).findByName(SourceSet.MAIN_SOURCE_SET_NAME));
150150
}

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

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.gradle.api.logging.Logger;
2828
import org.gradle.api.logging.Logging;
2929
import org.gradle.api.provider.Provider;
30+
import org.gradle.process.ExecOperations;
3031
import org.gradle.api.provider.ProviderFactory;
3132
import org.gradle.internal.jvm.Jvm;
3233
import org.gradle.internal.jvm.inspection.JavaInstallationRegistry;
@@ -75,13 +76,16 @@ public class GlobalBuildInfoPlugin implements Plugin<Project> {
7576
private final JavaInstallationRegistry javaInstallationRegistry;
7677
private final JvmMetadataDetector metadataDetector;
7778
private final ProviderFactory providers;
79+
private final ExecOperations execOperations;
7880

7981
@Inject
8082
public GlobalBuildInfoPlugin(
83+
ExecOperations execOperations,
8184
JavaInstallationRegistry javaInstallationRegistry,
8285
JvmMetadataDetector metadataDetector,
8386
ProviderFactory providers
8487
) {
88+
this.execOperations = execOperations;
8589
this.javaInstallationRegistry = javaInstallationRegistry;
8690
this.metadataDetector = metadataDetector;
8791
this.providers = providers;
@@ -249,7 +253,7 @@ private File findRuntimeJavaHome() {
249253
}
250254

251255
private String findJavaHome(String version) {
252-
Provider<String> javaHomeNames = providers.gradleProperty("org.gradle.java.installations.fromEnv").forUseAtConfigurationTime();
256+
Provider<String> javaHomeNames = providers.gradleProperty("org.gradle.java.installations.fromEnv");
253257
String javaHomeEnvVar = getJavaHomeEnvVarName(version);
254258

255259
// Provide a useful error if we're looking for a Java home version that we haven't told Gradle about yet
@@ -318,15 +322,18 @@ private static int findDefaultParallel(Project project) {
318322
}
319323
_defaultParallel = socketToCore.values().stream().mapToInt(i -> i).sum();
320324
} else if (OS.current() == OS.MAC) {
321-
// Ask macOS to count physical CPUs for us
322-
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
323-
project.exec(spec -> {
324-
spec.setExecutable("sysctl");
325-
spec.args("-n", "hw.physicalcpu");
326-
spec.setStandardOutput(stdout);
327-
});
328-
329-
_defaultParallel = Integer.parseInt(stdout.toString().trim());
325+
// On Apple silicon, we only want to use the performance cores
326+
boolean isAppleSilicon = project.getProviders().systemProperty("os.arch").getOrElse("").equals("aarch64");
327+
String query = isAppleSilicon && isMontereyOrNewer(project.getProviders())
328+
? "hw.perflevel0.physicalcpu"
329+
: "hw.physicalcpu";
330+
331+
String stdout = project.getProviders().exec(execSpec ->
332+
execSpec.commandLine("sysctl", "-n", query)
333+
).getStandardOutput().getAsText().get();
334+
335+
336+
_defaultParallel = Integer.parseInt(stdout.trim());
330337
}
331338

332339
_defaultParallel = Runtime.getRuntime().availableProcessors() / 2;
@@ -335,6 +342,20 @@ private static int findDefaultParallel(Project project) {
335342
return _defaultParallel;
336343
}
337344

345+
private final static int MACOS_MONTEREY_MAJOR_VERSION = 12;
346+
347+
private static boolean isMontereyOrNewer(ProviderFactory providers) {
348+
String rawVersion = providers.systemProperty("os.version").getOrElse("").trim();
349+
if (rawVersion.isEmpty()) {
350+
LOGGER.warn("Failed to validate MacOs version.");
351+
return false;
352+
}
353+
354+
String majorVersion = rawVersion.split("\\.")[0];
355+
356+
return Integer.parseInt(majorVersion) >= MACOS_MONTEREY_MAJOR_VERSION;
357+
}
358+
338359
public static GitInfo gitInfo(File rootDir) {
339360
try {
340361
/*

buildSrc/src/main/java/org/elasticsearch/hadoop/gradle/scala/SparkVariantPlugin.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@
3939
import org.gradle.api.file.ConfigurableFileCollection;
4040
import org.gradle.api.file.SourceDirectorySet;
4141
import org.gradle.api.internal.artifacts.repositories.resolver.ComponentMetadataDetailsAdapter;
42-
import org.gradle.api.internal.tasks.DefaultScalaSourceSet;
4342
import org.gradle.api.plugins.BasePlugin;
44-
import org.gradle.api.plugins.Convention;
4543
import org.gradle.api.plugins.JavaBasePlugin;
4644
import org.gradle.api.plugins.JavaPlugin;
47-
import org.gradle.api.plugins.JavaPluginConvention;
4845
import org.gradle.api.plugins.JavaPluginExtension;
4946
import org.gradle.api.tasks.SourceSet;
5047
import org.gradle.api.tasks.SourceSetContainer;

gradle/wrapper/gradle-wrapper.jar

59 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)