Jetpack Proto数据存储-使用Kotlin DSL进行Gradle配置

问题描述

在jetpack数据存储中,您必须set the gradle plugin task才能从.proto文件中生成类:

// build.gradle
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'
                }
            }
        }
    }
}

在我的项目中,我的gradle项目使用了 Kotlin dsl 。在尝试将其转换为kotlin dsl之后,option属性是未知的,我找不到它可以替代kotlin kts

// build.gradle.kts
protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:3.10.0"
    }
    generateProtoTasks {
        all().forEach { task ->
            task.builtins {
                java {
                    option = "lite" // ** option is unknown **
                }
            }
        }
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)