codelab-android-datastore icon indicating copy to clipboard operation
codelab-android-datastore copied to clipboard

how to config protobuf use kotlindsl in build.gradle ?

Open zs1973 opened this issue 3 years ago • 2 comments

copy gradle code from this build.gradle into my project, it not work

zs1973 avatar Mar 10 '21 12:03 zs1973

copy gradle code from this build.gradle into my project, it not work

protobuf { protoc { artifact = "com.google.protobuf:protoc:3.10.0" }

// Generates the java Protobuf-lite code for the Protobufs in this project. See
// https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
// for more information.
generateProtoTasks {
    all().each { task ->
        task.builtins {
            java {
                option 'lite'
            }
        }
    }
}

}

zs1973 avatar Mar 10 '21 12:03 zs1973

if you use the Gradle Kotlin DSL it should be like this

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:<version>"
    }

    generateProtoTasks {
        all().forEach { task ->
            task.builtins {
                id("java") {
                    option("lite")
                }
            }
        }
    }
}

chrimaeon avatar Apr 25 '21 09:04 chrimaeon