Add operator fun get to MergedProperties

This commit is contained in:
Jason Penilla 2023-11-28 20:09:03 -07:00
parent fa22ceecea
commit f5f4c97b96
No known key found for this signature in database
GPG key ID: 0E75A301420E48F8

View file

@ -28,13 +28,19 @@ import kotlin.reflect.KProperty
import org.gradle.api.Project
class MergedProperties(private val properties: List<Properties>) {
// val someProperty by mergedProperties
operator fun getValue(thisRef: Any?, property: KProperty<*>): String {
return get(property.name)
}
// mergedProperties["someProperty"] | mergedProperties.get("someProperty")
operator fun get(propertyName: String): String {
for (props in properties) {
if (props.containsKey(property.name)) {
return props.getProperty(property.name)
if (props.containsKey(propertyName)) {
return props.getProperty(propertyName)
}
}
error("No value for property '${property.name}'")
error("No value for property '$propertyName'")
}
companion object {