Home > OS >  How can I only generate kotlin src files from the protobuf gradle plugin?
How can I only generate kotlin src files from the protobuf gradle plugin?

Time:09-17

I am successfully generating kotlin src files, but my code still seems to reference the java files because both java kotlin are generated. I want to only use kotlin from my apps perspective once the files are generated. This is what I have currently

protobuf {
    generatedFilesBaseDir = "$projectDir/src"

    protoc {
        artifact = "com.google.protobuf:protoc:3.21.6"

    }
    plugins {. }

    generateProtoTasks {
        ofSourceSet("main").forEach { task ->
            task.builtins {
                id("kotlin")
            }
        }
    }
}

Generates something like this. I want to only expose kotlin src. Is that possible?

enter image description here

CodePudding user response:

This is not possible because the Kotlin sources are designed to build on top of the Java sources. Without the Java source code, the Kotlin proto API is not usable.

  • Related