diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/GradleCompat.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/GradleCompat.kt index 77e239a48..4b3b48aec 100644 --- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/GradleCompat.kt +++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/GradleCompat.kt @@ -24,18 +24,39 @@ internal inline val Project.runtimeConfiguration: Configuration internal inline fun > ObjectFactory.property( defaultValue: Any? = null, ): P { + val valueClass = V::class.java return when (P::class.java) { - ListProperty::class.java -> listProperty(V::class.java).apply { - if (defaultValue != null) convention(defaultValue as List) + ListProperty::class.java -> listProperty(valueClass).apply { + defaultValue ?: return@apply + if (defaultValue is Provider<*>) { + convention(defaultValue as Provider>) + } else { + convention(defaultValue as Iterable) + } } - SetProperty::class.java -> setProperty(V::class.java).apply { - if (defaultValue != null) convention(defaultValue as Set) + SetProperty::class.java -> setProperty(valueClass).apply { + defaultValue ?: return@apply + if (defaultValue is Provider<*>) { + convention(defaultValue as Provider>) + } else { + convention(defaultValue as Iterable) + } } - MapProperty::class.java -> mapProperty(String::class.java, V::class.java).apply { - if (defaultValue != null) convention(defaultValue as Map) + MapProperty::class.java -> mapProperty(String::class.java, valueClass).apply { + defaultValue ?: return@apply + if (defaultValue is Provider<*>) { + convention(defaultValue as Provider>) + } else { + convention(defaultValue as Map) + } } - else -> property(V::class.java).apply { - if (defaultValue != null) convention(defaultValue as V) + else -> property(valueClass).apply { + defaultValue ?: return@apply + if (defaultValue is Provider<*>) { + convention(defaultValue as Provider) + } else { + convention(defaultValue as V) + } } } as P }