This message was deleted.
# plugin-development
s
This message was deleted.
👆 2
t
related, since this is Kotlin, I have to add
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
to get my IDE to stop complaining about returning null from that
map
.
c
for Kotlin I’ve added this extension function:
Copy code
public inline fun <reified S> Provider<S>.filter(crossinline predicate: (S) -> Boolean): Provider<S> {
    return flatMap {
        if (predicate(it)) {
            Providers.of(it)
        } else {
            Providers.notDefined()
        }
    }
}
sidesteps the null check by doing what Gradle does internally when
null
is returned - use
Providers.notDefined()
. The
flatMap
is there to unwrap the providers.
Copy code
baseline.set(extension.baseline.filter { it.asFile.exists() })
👍 1