[Properties] Support property key being both value and a prefix for other keys
What is your use-case and why do you need this feature?
In gradle.properties, we can have the following properties:
org.gradle.unsafe.configuration-cache=true
org.gradle.unsafe.configuration-cache.max-problems=0
This creates a conflict. Because we can't have both at the same time:
@Serializable
data class UnsafeProperties(
val `configuration-cache`: Boolean
)
@Serializable
data class UnsafeProperties(
val `configuration-cache`: ConfigCacheProps
)
@Serializable
data class ConfigCacheProps(
val `max-problems`: Int
)
Describe the solution you'd like
Maybe something like this?
@Serializable
data class UnsafeProperties(
val `configuration-cache`: Pair<Boolean,ConfigCacheProps>
)
It might not make sense to use Pair, in which case a specialized class similar to Pair could be used?
My current workaround is to change the key to org.gradle.unsafe.configuration-cache.enabled before deserializing.
Maybe a better solution might look like:
@Serializable
data class ConfigCacheProps(
@PropertyValue
val enabled: Boolean,
val `max-problems`: Int
)
Where @PropertyValue is a new annotation that would indicate to serialize and deserialize according to the prefix for the object and exclude the name of the property (exclude ".enabled", making the associate key "org.gradle.unsafe.configuration-cache" and not "org.gradle.unsafe.configuration-cache.enabled"). There could only be one @PropertyValue per class. Similar to @pdvrieze 's nl.adaptivity.xmlutil.serialization.XmlValue