Slackbot
03/06/2023, 1:49 PMVampire
03/06/2023, 3:35 PMnull
, the convention value is used.
If there is no convention value or you set it to provider { null }
, the provider has no value and gives an exception if you query it for its value.
(This inconsistency is topic of https://github.com/gradle/gradle/issues/14768 btw.)Javi
03/06/2023, 4:35 PMProperty<String>
is like Java development (at least old versions). You get the null in runtime if you don't do manual checks with if
or whatever.
I would like to have null safety to ensure a property cannot be null, currently you can
val someProp: Property<String> = objects.property<String>().convention() // you don't set any value
And it will crash, but it shouldn't compile.Javi
03/06/2023, 4:36 PMnull
must not be valid, only if explicitly the type is String?
(or there is a NullableProperty
)
someProperty.set(null)
Javi
03/06/2023, 4:38 PMrestoreConvention
is the way I would choose so in the future we can have null safety on propertiesVampire
03/06/2023, 9:05 PMnull
does not set it to null
, it sets it to the convention or to unset if there is no convention. You can chain providers, so that if it is unset a different provider is evaluated and so on. No provider can have a null
value currently.
And regarding "is like Java development", well, it is Java development. It is a Java class.