Skip to content

Commit f850358

Browse files
committed
Addressed PR comments
1 parent 5584d17 commit f850358

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static Optional<Duration> durationSysPropertyOrEnvVariable(String sysPropertyNam
5050

5151
static Optional<String> envVariable(String name, ProviderFactory providers) {
5252
if (isGradle65OrNewer() && !isGradle74OrNewer()) {
53-
Provider<String> variable = reflectionForUseAtConfigurationTime(providers.environmentVariable(name));
53+
Provider<String> variable = forUseAtConfigurationTime(providers.environmentVariable(name));
5454
return Optional.ofNullable(variable.getOrNull());
5555
}
5656
return Optional.ofNullable(System.getenv(name));
@@ -66,7 +66,7 @@ static Optional<Duration> durationEnvVariable(String name, ProviderFactory provi
6666

6767
static Optional<String> sysProperty(String name, ProviderFactory providers) {
6868
if (isGradle65OrNewer() && !isGradle74OrNewer()) {
69-
Provider<String> property = reflectionForUseAtConfigurationTime(providers.systemProperty(name));
69+
Provider<String> property = forUseAtConfigurationTime(providers.systemProperty(name));
7070
return Optional.ofNullable(property.getOrNull());
7171
}
7272
return Optional.ofNullable(System.getProperty(name));
@@ -267,12 +267,12 @@ private static Optional<URI> toUri(String scheme, String host, String path) {
267267
}
268268
}
269269

270-
private static <T> Provider<T> reflectionForUseAtConfigurationTime(Provider<T> provider) {
270+
private static Provider<String> forUseAtConfigurationTime(Provider<String> provider) {
271271
if (isGradle65OrNewer() && !isGradle74OrNewer()) {
272272
try {
273273
// Use reflection to access the forUseAtConfigurationTime method as it was removed in Gradle 9.
274274
Method method = Provider.class.getMethod("forUseAtConfigurationTime");
275-
return (Provider<T>) method.invoke(provider);
275+
return (Provider<String>) method.invoke(provider);
276276
} catch (Exception e) {
277277
throw new RuntimeException("Failed to invoke forUseAtConfigurationTime via reflection", e);
278278
}

0 commit comments

Comments
 (0)