How to build Google protocol buffers and Kotlin using Gradle?

前端 未结 3 1389
灰色年华
灰色年华 2021-02-13 05:07

I\'m trying to build a project that uses both Google protocol buffers and Kotlin using Gradle. I want the proto files to compile into Java source, which is then called from my K

3条回答
  •  醉话见心
    2021-02-13 05:08

    I was able to get this to work by adding two lines to my build.gradle.

    The first line adds the directory in which the proto compiler generates Java code to the directories the :compileKotlin looks for Java source:

    sourceSets.main.java.srcDirs += 'build/generated/source/proto/main/java'
    

    The second ensures that the Java code is (re)generated before invoking :compileKotlin:

    compileKotlin.dependsOn ':generateProto'
    

提交回复
热议问题