Skip to content

Commit 712f91a

Browse files
committed
Remove overloading GradleUtilsExtension#unpack methods
These methods cause a GroovyRuntimeException as the runtime invoker cannot choose between some of the overloading methods. This bug is rare and only happens in composite builds, but that unfortunately affects Git Version. This is unfortunately a binary breaking change but does not affect buildscripts. Plugins that shadow GradleUtils Shared are unaffected, and there shouldn't be any plugins that are compiled to use GradleUtils at runtime.
1 parent e01febc commit 712f91a

File tree

2 files changed

+10
-130
lines changed

2 files changed

+10
-130
lines changed

gradleutils-shared/src/main/java/net/minecraftforge/gradleutils/shared/SharedUtil.java

Lines changed: 10 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -471,70 +471,6 @@ public static String pathify(Dependency dependency) {
471471

472472
//region Deferred Objects
473473

474-
/// Unpacks a deferred value.
475-
///
476-
/// @param value The value to unpack
477-
/// @param <T> The type of value held by the provider
478-
/// @return The unpacked value
479-
/// @see #unpack(Object)
480-
public static <T> T unpack(Provider<T> value) {
481-
return value.get();
482-
}
483-
484-
/// Unpacks a deferred value.
485-
///
486-
/// @param value The value to unpack
487-
/// @param <T> The type of value held by the provider
488-
/// @return The unpacked value
489-
/// @see #unpack(Object)
490-
public static <T> T unpack(ProviderConvertible<T> value) {
491-
return value.asProvider().get();
492-
}
493-
494-
/// Unpacks a deferred value.
495-
///
496-
/// @param value The value to unpack
497-
/// @param <T> The type of value held by the provider
498-
/// @return The unpacked value
499-
/// @see #unpack(Object)
500-
public static <T> T unpack(Closure<T> value) {
501-
return Closures.invoke(value);
502-
}
503-
504-
/// Unpacks a deferred value.
505-
///
506-
/// @param value The value to unpack
507-
/// @param <T> The type of value held by the provider
508-
/// @return The unpacked value
509-
/// @see #unpack(Object)
510-
public static <T> T unpack(Callable<T> value) {
511-
try {
512-
return value.call();
513-
} catch (Exception e) {
514-
throw new RuntimeException(e);
515-
}
516-
}
517-
518-
/// Unpacks a deferred value.
519-
///
520-
/// @param value The value to unpack
521-
/// @param <T> The type of value held by the provider
522-
/// @return The unpacked value
523-
/// @see #unpack(Object)
524-
public static <T> T unpack(Function0<T> value) {
525-
return value.invoke();
526-
}
527-
528-
/// Unpacks a deferred value.
529-
///
530-
/// @param value The value to unpack
531-
/// @param <T> The type of value held by the provider
532-
/// @return The unpacked value
533-
/// @see #unpack(Object)
534-
public static <T> T unpack(Supplier<T> value) {
535-
return value.get();
536-
}
537-
538474
/// Unpacks a deferred value.
539475
///
540476
/// Since buildscripts are dynamically compiled, this allows buildscript authors to use this method with version
@@ -547,17 +483,21 @@ public static <T> T unpack(Supplier<T> value) {
547483
@SuppressWarnings("unchecked")
548484
public static <T> T unpack(Object value) {
549485
if (value instanceof ProviderConvertible<?> deferred) {
550-
return (T) unpack(deferred);
486+
return (T) deferred.asProvider().get();
551487
} else if (value instanceof Provider<?> deferred) {
552-
return (T) unpack(deferred);
488+
return (T) deferred.get();
553489
} else if (value instanceof Closure<?> deferred) {
554-
return (T) unpack(deferred);
490+
return Closures.invoke(deferred);
555491
} else if (value instanceof Callable<?> deferred) {
556-
return (T) unpack(deferred);
492+
try {
493+
return (T) deferred.call();
494+
} catch (Exception e) {
495+
throw new RuntimeException(e);
496+
}
557497
} else if (value instanceof Function0<?> deferred) {
558-
return (T) unpack(deferred);
498+
return (T) deferred.invoke();
559499
} else if (value instanceof Supplier<?> deferred) {
560-
return (T) unpack(deferred);
500+
return (T) deferred.get();
561501
} else {
562502
return (T) value;
563503
}

src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsExtension.java

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -275,66 +275,6 @@ default Action<MavenArtifactRepository> getPublishingForgeMaven(Provider<?> defa
275275

276276
/* MISCELLANEOUS */
277277

278-
/// Unpacks a deferred value.
279-
///
280-
/// @param value The value to unpack
281-
/// @param <T> The type of value held by the provider
282-
/// @return The unpacked value
283-
/// @see #unpack(Object)
284-
default <T> T unpack(Provider<T> value) {
285-
return Util.unpack(value);
286-
}
287-
288-
/// Unpacks a deferred value.
289-
///
290-
/// @param value The value to unpack
291-
/// @param <T> The type of value held by the provider
292-
/// @return The unpacked value
293-
/// @see #unpack(Object)
294-
default <T> T unpack(ProviderConvertible<T> value) {
295-
return Util.unpack(value);
296-
}
297-
298-
/// Unpacks a deferred value.
299-
///
300-
/// @param value The value to unpack
301-
/// @param <T> The type of value held by the provider
302-
/// @return The unpacked value
303-
/// @see #unpack(Object)
304-
default <T> T unpack(Closure<T> value) {
305-
return Util.unpack(value);
306-
}
307-
308-
/// Unpacks a deferred value.
309-
///
310-
/// @param value The value to unpack
311-
/// @param <T> The type of value held by the provider
312-
/// @return The unpacked value
313-
/// @see #unpack(Object)
314-
default <T> T unpack(Callable<T> value) {
315-
return Util.unpack(value);
316-
}
317-
318-
/// Unpacks a deferred value.
319-
///
320-
/// @param value The value to unpack
321-
/// @param <T> The type of value held by the provider
322-
/// @return The unpacked value
323-
/// @see #unpack(Object)
324-
default <T> T unpack(Function0<T> value) {
325-
return Util.unpack(value);
326-
}
327-
328-
/// Unpacks a deferred value.
329-
///
330-
/// @param value The value to unpack
331-
/// @param <T> The type of value held by the provider
332-
/// @return The unpacked value
333-
/// @see #unpack(Object)
334-
default <T> T unpack(Supplier<T> value) {
335-
return Util.unpack(value);
336-
}
337-
338278
/// Unpacks a deferred value.
339279
///
340280
/// Since buildscripts are dynamically compiled, this allows buildscript authors to use this method with version

0 commit comments

Comments
 (0)