Skip to content

Commit 37916c2

Browse files
authored
Merge pull request #419 from gradle/gk/gradle9.0
Gradle 9.0 upgrade and fixes
2 parents 09310f0 + f850358 commit 37916c2

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

gradle/wrapper/gradle-wrapper.jar

1.65 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=bd71102213493060956ec229d946beee57158dbd89d0e62b91bca0fa2c5f3531
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
3+
distributionSha256Sum=8fad3d78296ca518113f3d29016617c7f9367dc005f932bd9d93bf45ba46072b
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.

src/main/java/com/gradle/Utils.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.io.InputStreamReader;
1717
import java.io.Reader;
1818
import java.io.UnsupportedEncodingException;
19+
import java.lang.reflect.Method;
1920
import java.net.URI;
2021
import java.net.URISyntaxException;
2122
import java.net.URLEncoder;
@@ -49,7 +50,7 @@ static Optional<Duration> durationSysPropertyOrEnvVariable(String sysPropertyNam
4950

5051
static Optional<String> envVariable(String name, ProviderFactory providers) {
5152
if (isGradle65OrNewer() && !isGradle74OrNewer()) {
52-
@SuppressWarnings("deprecation") Provider<String> variable = providers.environmentVariable(name).forUseAtConfigurationTime();
53+
Provider<String> variable = forUseAtConfigurationTime(providers.environmentVariable(name));
5354
return Optional.ofNullable(variable.getOrNull());
5455
}
5556
return Optional.ofNullable(System.getenv(name));
@@ -65,7 +66,7 @@ static Optional<Duration> durationEnvVariable(String name, ProviderFactory provi
6566

6667
static Optional<String> sysProperty(String name, ProviderFactory providers) {
6768
if (isGradle65OrNewer() && !isGradle74OrNewer()) {
68-
@SuppressWarnings("deprecation") Provider<String> property = providers.systemProperty(name).forUseAtConfigurationTime();
69+
Provider<String> property = forUseAtConfigurationTime(providers.systemProperty(name));
6970
return Optional.ofNullable(property.getOrNull());
7071
}
7172
return Optional.ofNullable(System.getProperty(name));
@@ -266,6 +267,20 @@ private static Optional<URI> toUri(String scheme, String host, String path) {
266267
}
267268
}
268269

270+
private static Provider<String> forUseAtConfigurationTime(Provider<String> provider) {
271+
if (isGradle65OrNewer() && !isGradle74OrNewer()) {
272+
try {
273+
// Use reflection to access the forUseAtConfigurationTime method as it was removed in Gradle 9.
274+
Method method = Provider.class.getMethod("forUseAtConfigurationTime");
275+
return (Provider<String>) method.invoke(provider);
276+
} catch (Exception e) {
277+
throw new RuntimeException("Failed to invoke forUseAtConfigurationTime via reflection", e);
278+
}
279+
} else {
280+
return provider;
281+
}
282+
}
283+
269284
private Utils() {
270285
}
271286

0 commit comments

Comments
 (0)