4

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:

  1. I can see catalog.proto in a classpath, but cannot import it from scratch
  2. catalog.proto don't have any package declaration

As 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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.