gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.99k stars 4.77k forks source link

Add Assignment for Provider convertibles #31383

Open DRSchlaubi opened 5 days ago

DRSchlaubi commented 5 days ago

Expected Behavior

Currently if you try to use the Kotlin DSL assignment operator with a provider convertible, it fails because it only supports providers

Current Behavior (optional)

No response

Context

this can be caused by the following configuration

[versions]
version = "1"
version-b = "2"
interface Extension {
  val foo: Property<String>
}

val theExtension by extensions.creating(Extension::class)

theExtension.foo = libs.version.b // works as "b" is a Provider<String>
theExtension.foo = libs.version // Fails as "version" is a ProviderConvertible<String>
ov7a commented 1 day ago

The issue is in the backlog of the relevant team, but the existence of a workaround means it might take a while before a fix is made.


The (ugly) workaround is to use .asProvider() to convert from ProviderConvertible<String> to Provider.

Probably the ProviderConvertible should delegate to Provider more transparently.