xolstice / protobuf-maven-plugin

Maven Plugin that executes the Protocol Buffers (protoc) compiler
https://www.xolstice.org/protobuf-maven-plugin/
Other
232 stars 76 forks source link

how to set protobuf include path? #44

Closed wenweihu86 closed 5 years ago

wenweihu86 commented 5 years ago

Is your feature request related to a problem? Please describe. In my proto file, I want to import protobuf include proto, such as: import "google/protobuf/descriptor.proto";

Describe the solution you'd like can config in pom.xml

Describe alternatives you've considered no

Additional context no

sergei-ivanov commented 5 years ago

You need to include google protobuf library as a dependency. You will need it in any case if you are going to generate and compile java sources. Everything else happens automatically.

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>3.6.1</version>
        </dependency>
wenweihu86 commented 5 years ago

@sergei-ivanov thanks

wenweihu86 commented 5 years ago

@sergei-ivanov i tried the following pom.xml, but it failed.

            <groupId>org.xolstice.maven.plugins</groupId>
            <artifactId>protobuf-maven-plugin</artifactId>
            <version>0.6.1</version>
            <configuration>
                <clearOutputDirectory>false</clearOutputDirectory>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.google.protobuf</groupId>
                    <artifactId>protobuf-java</artifactId>
                    <version>2.5.0</version>
                </dependency>
            </dependencies>
        </plugin>
sergei-ivanov commented 5 years ago

As I mentioned on Gitter, version 2.5.0 of protobuf library is very old and it may not have google/protobuf/descriptor.proto file packaged. Check the contents of the JAR file. If you really need to use that old protobuf library, you may need to roll your own JAR dependency with .proto files for version 2.5.0 bundled into it.

wenweihu86 commented 5 years ago

ok,thanks