xolstice / protobuf-maven-plugin

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

the import files of the proto file will be code generation #60

Open yinghuzhu opened 5 years ago

yinghuzhu commented 5 years ago

the import files of the proto file can be code generation as well if there is some import file in the proto file . So, we add a parameter "generateImport"

the plugin is config like below:

<plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <configuration>
                    <generateImport>true</generateImport>
                    <protoSourceRoot>${proto.source.root}</protoSourceRoot>
                    <includes>
                        ${proto}
                    </includes>
                    <outputDirectory>${project.basedir}/src/main/java</outputDirectory>
                    <clearOutputDirectory>false</clearOutputDirectory>
                    <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:${protoc-gen-grpc-java.version}:exe:${os.detected.classifier}</pluginArtifact>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
sergei-ivanov commented 5 years ago

Hi, I am not sure what kind of problem you are trying to solve by this pull request, because you seem to be replicating the logic of protobuf compiler. Can you create a minimal sample project on github to demonstrate what you are trying to do and why the existing options do not cover your use case.

yinghuzhu commented 5 years ago

we have a lot of proto files . but, we just expect that a few proto file is code generation instead of all. So, we hope that the only specified file and the import files are generated . Also, I have a example: https://github.com/yinghuzhu/grpc-sample the maven command like this: mvn clean package -Dproto=sample/sample.proto the command only generate sample/sample.proto. Actually, we hope sample/sample.proto, product/product.proto and common/common.proto can be code generation