androidkotlingradlegroovy

In Gradle Kotlin, how to iterate like each{} in Groovy?


In the Android doc, there's a build.gradle snippet describing the set up for com.google.protobuf:

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc"
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    option 'lite'
                }
            }
        }
    }
}

However it is Groovy syntax, which doesn't work for Kotlin. The IDE highlights each saying something like "unresolved reference".

So what's the alternative for each {} in Kotlin?


Solution

  • ...
    all().configureEach { task ->
    ...
    

    (from here)