Open
Description
openedon Oct 18, 2022
Current protobuf-gradle-plugin API requires 25 lines in gradle.build.kts
(16 without comments) for the most common trivial case:
It looks like an unnecessary complication, so I wonder what would you think of providing the following API instead:
dependencies {
// A configuration where end-users could declare the relevant protobuf dependency
protobufCompiler("com.google.protobuf:protoc:3.21.7")
// Plain files are supported by Gradle: https://docs.gradle.org/current/userguide/declaring_dependencies.html#sub:file_dependencies
// protobufCompiler(files("/path/to/protobuf/compiler"))
// I'm not sure regarding the name, however, the idea is that each sourceSet
// could create a configuration for attaching "protoc plugins" just like "implementation, api, compileOnly, etc" configurations
// are created for each source set
// Let us imagine that protobufPlugin("...") declares dependencies for "protoc tasks for the main source set"
protobufPlugin("io.grpc:protoc-gen-grpc-java:1.50.0")
// testProtobufPlugin declares dependencies for "protoc tasks for the test source set" (~ like testImplementation)
testProtobufPlugin("io.grpc:protoc-gen-grpc-java:1.50.0")
}
That completely removes the need for protobuf { plugins {...}, generateProtoTasks { of...}
, and I believe, it makes the common case much easier to understand and manage.
In other words, "adding protobuf-gradle-plugin" would look as follows:
plugins {
id("java-library")
+ id("com.google.protobuf") version "0.8.19"
}
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.9.1")
+ protobufCompiler("com.google.protobuf:protoc:3.21.7")
+ protobufPlugin("io.grpc:protoc-gen-grpc-java:1.50.0")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment