gradle-scripts icon indicating copy to clipboard operation
gradle-scripts copied to clipboard

Generate Kotlin DSL builder for protobuf messages

Open ks-yim opened this issue 2 years ago • 3 comments

Motivation:

Currently, java-rpc-proto.gradle does not generate Kotlin DSL builder for protobuf messages even when the project is flagged with kotlin-grpc.

Registering kotlin plugin within generateProtoTasks closure will make it generate Kotlin DSL builder for protobuf mesages.

generateProtoTasks {
    if (project.ext.hasFlag('kotlin-grpc') && ...) {
        kotlinGrpc {}
        // Apply `kotlin` plugin to generate DSL builder.
        kotlin {}
    }
}

ks-yim avatar Nov 14 '23 14:11 ks-yim

It sounds like a good idea.

ikhoon avatar Nov 15 '23 02:11 ikhoon

Did some tests, and the right way to add kotlin plugin would be the following. The original approach emits a warning.

generateProtoTasks {
    all().forEach { it ->
        it.plugins {
            kotlinGrpc {}
        }
        it.builtins {
            kotlin {}
        }
    }
}

I will send a PR ~ 😆

ks-yim avatar Nov 15 '23 02:11 ks-yim

Unfortunately, there are no tests in this repo. Would you send a PR to Armeria first so that we easily check if the option correctly generates Kotlin DSL in the PR review? 😉

ikhoon avatar Nov 28 '23 02:11 ikhoon