I need to write in Kotlin DSL: filter {lin...
# announcements
j
I need to write in Kotlin DSL: filter {line -> if (true/*some condition*/) line else null } Filter is defined here: https://docs.gradle.org/current/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:filter(org.gradle.api.Transformer) But compiler does not compile it, because null is not String. Filter is defined in java and null is allowed there. How to write it in Kotlin?
j
Is the Java type declared as non null? Else that should work
h
#C19FD9681
j
They are not declared as not null: public AbstractCopyTask filter(Transformer<String, String> transformer) {....
It is problem idea and kts. Idea shows error on this kts file, but in runtime or in kt file it is ok.