I want to import a proto file from a gradle dependencies and have next structure (simplified for redability):
dependency-project:
- models:
catalog.proto
my-project:
- source:
client.proto
In a client.proto I want to reuse some models, which defined in a catalog.proto.
syntax = "proto3";
package client;
import "google/protobuf/descriptor.proto";
import "classpath/catalog.proto"; // ???
...
My build.gradle.kts:
dependencies {
...
implementation("com.google.protobuf:protobuf-java:$protoBufCoreVersion")
implementation("com.thesamet.scalapb.common-protos:proto-google-common-protos-scalapb_0.9_2.13:2.5.0-3") // trying to reuse
}
apply(plugin = "com.google.protobuf")
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:$protoBufCoreVersion"
/// probably here I need to use new lib
}
}
...
But have next problems:
catalog.proto in a classpath, but cannot import it from scratchcatalog.proto don't have any package declarationAs far as I know, there are some available solutions for scala, but I'm using gradle in Java/Kotlin project with gradle and don't understand how to reuse such approach. Also, I found that such usage of proto files (for building new models using .proto files) is not convinient. Is it possible at all?
In case anyone still need it: you need to use Protobuf Plugin for Gradle, check out my answer here for more details: https://stackoverflow.com/a/73822802/2185783.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With