Skip to content

Commit 4cafa7e

Browse files
breskebymasseyke
andauthored
Update Gradle wrapper to 8.0.2 (#2070)
* Use gradle 8.0.2 * Fix deprecation warnings with Gradle 8x and incompatibilties * Add more heap to address additional memory demands of gradle 8x * Fixing the build --------- Co-authored-by: Keith Massey <keith.massey@elastic.co>
1 parent 97ecb5a commit 4cafa7e

File tree

12 files changed

+136
-41
lines changed

12 files changed

+136
-41
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,17 +507,17 @@ class BuildPlugin implements Plugin<Project> {
507507
pack.dependsOn(project.tasks.jar)
508508
pack.dependsOn(project.tasks.javadocJar)
509509
pack.dependsOn(project.tasks.sourcesJar)
510-
pack.outputs.files(project.tasks.jar.archivePath, project.tasks.javadocJar.archivePath, project.tasks.sourcesJar.archivePath)
510+
pack.outputs.files(project.tasks.jar.getArchiveFile(), project.tasks.javadocJar.getArchiveFile(), project.tasks.sourcesJar.getArchiveFile().get().getAsFile())
511511
project.getPlugins().withType(SparkVariantPlugin).whenPluginAdded {
512512
SparkVariantPluginExtension sparkVariants = project.getExtensions().getByType(SparkVariantPluginExtension.class)
513513
sparkVariants.featureVariants { SparkVariant variant ->
514514
pack.dependsOn(project.tasks.getByName(variant.taskName('jar')))
515515
pack.dependsOn(project.tasks.getByName(variant.taskName('javadocJar')))
516516
pack.dependsOn(project.tasks.getByName(variant.taskName('sourcesJar')))
517517
pack.outputs.files(
518-
project.tasks.getByName(variant.taskName('jar')).archivePath,
519-
project.tasks.getByName(variant.taskName('javadocJar')).archivePath,
520-
project.tasks.getByName(variant.taskName('sourcesJar')).archivePath
518+
project.tasks.getByName(variant.taskName('jar')).getArchiveFile().get().getAsFile(),
519+
project.tasks.getByName(variant.taskName('javadocJar')).getArchiveFile().get().getAsFile(),
520+
project.tasks.getByName(variant.taskName('sourcesJar')).getArchiveFile().get().getAsFile()
521521
)
522522
}
523523
}

buildSrc/src/main/groovy/org/elasticsearch/hadoop/gradle/fixture/hadoop/InstanceInfo.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class InstanceInfo {
118118
* as well as a groovy AntBuilder, to enable running ant condition checks. The default wait
119119
* condition is for http on the http port.
120120
*/
121-
Closure waitCondition = { InstanceInfo instanceInfo, AntBuilder ant ->
121+
Closure waitCondition = { InstanceInfo instanceInfo, groovy.ant.AntBuilder ant ->
122122
String waitUrl = instanceInfo.httpUri()
123123
if (waitUrl == null) {
124124
return true

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void apply(Project project) {
104104
params.setRuntimeJavaHome(runtimeJavaHome);
105105
params.setRuntimeJavaVersion(determineJavaVersion("runtime java.home", runtimeJavaHome, minimumRuntimeVersion));
106106
params.setIsRuntimeJavaHomeSet(Jvm.current().getJavaHome().equals(runtimeJavaHome) == false);
107-
JvmInstallationMetadata runtimeJdkMetaData = metadataDetector.getMetadata(getJavaInstallation(runtimeJavaHome).getLocation());
107+
JvmInstallationMetadata runtimeJdkMetaData = metadataDetector.getMetadata(getJavaInstallation(runtimeJavaHome));
108108
params.setJavaVersions(getAvailableJavaVersions());
109109
params.setMinimumCompilerVersion(minimumCompilerVersion);
110110
params.setMinimumRuntimeVersion(minimumRuntimeVersion);
@@ -127,16 +127,15 @@ private void logGlobalBuildInfo() {
127127
final String osVersion = System.getProperty("os.version");
128128
final String osArch = System.getProperty("os.arch");
129129
final Jvm gradleJvm = Jvm.current();
130-
JvmInstallationMetadata gradleJvmMetadata = metadataDetector.getMetadata(gradleJvm.getJavaHome());
130+
JvmInstallationMetadata gradleJvmMetadata = metadataDetector.getMetadata(getJavaInstallation(gradleJvm.getJavaHome()));
131131
final String gradleJvmVendorDetails = gradleJvmMetadata.getVendor().getDisplayName();
132132
LOGGER.quiet("=======================================");
133133
LOGGER.quiet("Elasticsearch Build Hamster says Hello!");
134134
LOGGER.quiet(" Gradle Version : " + GradleVersion.current().getVersion());
135135
LOGGER.quiet(" OS Info : " + osName + " " + osVersion + " (" + osArch + ")");
136136
if (BuildParams.getIsRuntimeJavaHomeSet()) {
137-
final String runtimeJvmVendorDetails = metadataDetector.getMetadata(BuildParams.getRuntimeJavaHome())
138-
.getVendor()
139-
.getDisplayName();
137+
JvmInstallationMetadata runtimeJvm = metadataDetector.getMetadata(getJavaInstallation(BuildParams.getRuntimeJavaHome()));
138+
final String runtimeJvmVendorDetails = runtimeJvm.getVendor().getDisplayName();
140139
LOGGER.quiet(" Runtime JDK Version : " + BuildParams.getRuntimeJavaVersion() + " (" + runtimeJvmVendorDetails + ")");
141140
LOGGER.quiet(" Runtime java.home : " + BuildParams.getRuntimeJavaHome());
142141
LOGGER.quiet(" Gradle JDK Version : " + gradleJvm.getJavaVersion() + " (" + gradleJvmVendorDetails + ")");
@@ -152,7 +151,7 @@ private void logGlobalBuildInfo() {
152151

153152
private JavaVersion determineJavaVersion(String description, File javaHome, JavaVersion requiredVersion) {
154153
InstallationLocation installation = getJavaInstallation(javaHome);
155-
JavaVersion actualVersion = metadataDetector.getMetadata(installation.getLocation()).getLanguageVersion();
154+
JavaVersion actualVersion = metadataDetector.getMetadata(installation).getLanguageVersion();
156155
if (actualVersion.isCompatibleWith(requiredVersion) == false) {
157156
throwInvalidJavaHomeException(
158157
description,
@@ -186,7 +185,7 @@ private boolean isSameFile(File javaHome, InstallationLocation installationLocat
186185
private List<JavaHome> getAvailableJavaVersions() {
187186
return getAvailableJavaInstallationLocationSteam().map(installationLocation -> {
188187
File installationDir = installationLocation.getLocation();
189-
JvmInstallationMetadata metadata = metadataDetector.getMetadata(installationDir);
188+
JvmInstallationMetadata metadata = metadataDetector.getMetadata(installationLocation);
190189
int actualVersion = Integer.parseInt(metadata.getLanguageVersion().getMajorVersion());
191190
return JavaHome.of(actualVersion, providers.provider(() -> installationDir));
192191
}).collect(Collectors.toList());

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
import org.gradle.api.tasks.bundling.Jar;
5555
import org.gradle.api.tasks.scala.ScalaDoc;
5656
import org.gradle.api.tasks.testing.Test;
57-
import org.gradle.util.ConfigureUtil;
5857

5958
import static org.gradle.api.plugins.JavaBasePlugin.DOCUMENTATION_GROUP;
6059
import static org.gradle.api.plugins.JavaBasePlugin.VERIFICATION_GROUP;
@@ -71,6 +70,8 @@
7170
import static org.gradle.api.tasks.SourceSet.MAIN_SOURCE_SET_NAME;
7271
import static org.gradle.api.tasks.SourceSet.TEST_SOURCE_SET_NAME;
7372

73+
import org.elasticsearch.hadoop.gradle.util.ConfigureUtil;
74+
7475
public class SparkVariantPlugin implements Plugin<Project> {
7576

7677
public static class SparkVariant {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Copyright 2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.elasticsearch.hadoop.gradle.util;
18+
19+
import groovy.lang.Closure;
20+
import org.codehaus.groovy.runtime.GeneratedClosure;
21+
import org.gradle.api.Action;
22+
import org.gradle.internal.metaobject.DynamicObjectUtil;
23+
import org.gradle.internal.Actions;
24+
import org.gradle.internal.metaobject.ConfigureDelegate;
25+
import org.gradle.internal.metaobject.DynamicInvokeResult;
26+
import org.gradle.internal.metaobject.DynamicObject;
27+
import org.gradle.util.internal.ClosureBackedAction;
28+
29+
import javax.annotation.Nullable;
30+
import java.util.Collection;
31+
import java.util.Map;
32+
33+
import static org.gradle.util.internal.CollectionUtils.toStringList;
34+
35+
public class ConfigureUtil {
36+
37+
/**
38+
* Creates an action that uses the given closure to configure objects of type T.
39+
*/
40+
public static <T> Action<T> configureUsing(@Nullable final Closure configureClosure) {
41+
if (configureClosure == null) {
42+
return Actions.doNothing();
43+
}
44+
45+
return new WrappedConfigureAction<T>(configureClosure);
46+
}
47+
48+
public static <T> T configure(@Nullable Closure configureClosure, T target) {
49+
if (configureClosure == null) {
50+
return target;
51+
}
52+
53+
configureTarget(configureClosure, target, new ConfigureDelegate(configureClosure, target));
54+
55+
return target;
56+
}
57+
58+
59+
private static <T> void configureTarget(Closure configureClosure, T target, ConfigureDelegate closureDelegate) {
60+
if (!(configureClosure instanceof GeneratedClosure)) {
61+
new ClosureBackedAction<T>(configureClosure, Closure.DELEGATE_FIRST, false).execute(target);
62+
return;
63+
}
64+
65+
// Hackery to make closure execution faster, by short-circuiting the expensive property and method lookup on Closure
66+
Closure withNewOwner = configureClosure.rehydrate(target, closureDelegate, configureClosure.getThisObject());
67+
new ClosureBackedAction<T>(withNewOwner, Closure.OWNER_ONLY, false).execute(target);
68+
}
69+
70+
public static class WrappedConfigureAction<T> implements Action<T> {
71+
private final Closure configureClosure;
72+
73+
WrappedConfigureAction(Closure configureClosure) {
74+
this.configureClosure = configureClosure;
75+
}
76+
77+
@Override
78+
public void execute(T t) {
79+
configure(configureClosure, t);
80+
}
81+
82+
public Closure getConfigureClosure() {
83+
return configureClosure;
84+
}
85+
}
86+
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ systemProp.org.gradle.warning.mode=fail
33

44
## Settings
55
org.gradle.daemon=false
6+
org.gradle.jvmargs=-Xmx4g
67

78
# java homes resolved by environment variables
89
org.gradle.java.installations.auto-detect=false

gradle/wrapper/gradle-wrapper.jar

1.19 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ set -- \
205205
org.gradle.wrapper.GradleWrapperMain \
206206
"$@"
207207

208+
# Stop when "xargs" is not available.
209+
if ! command -v xargs >/dev/null 2>&1
210+
then
211+
die "xargs is not available"
212+
fi
213+
208214
# Use "xargs" to parse quoted args.
209215
#
210216
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

gradlew.bat

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,7 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
2929
set APP_BASE_NAME=%~n0
3030
set APP_HOME=%DIRNAME%
3131

@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4040

4141
set JAVA_EXE=java.exe
4242
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
43+
if %ERRORLEVEL% equ 0 goto execute
4444

4545
echo.
4646
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7575

7676
:end
7777
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
78+
if %ERRORLEVEL% equ 0 goto mainEnd
7979

8080
:fail
8181
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8282
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
83+
set EXIT_CODE=%ERRORLEVEL%
84+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
85+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86+
exit /b %EXIT_CODE%
8587

8688
:mainEnd
8789
if "%OS%"=="Windows_NT" endlocal

0 commit comments

Comments
 (0)