-
|
How do I reproduce the behavior of https://github.com/moby/buildkit/blob/f2ce016376e5e61ff87d95cd20ccdf108fa77230/hack/dockerfiles/generated-files.Dockerfile#L78 using this plugin? My understanding is that they are passing a single proto files into This generates code for the proto file being passed in, in addition to any 3rd-party types it imports. How can I do the same thing using this plugin? If I place the main and 3rd-party proto files in a single directory, and pass that in as |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hey. There is a pair of parameters Pass the directories of the sources into Example of the Parameter documentation: https://ascopes.github.io/protobuf-maven-plugin/generate-mojo.html#includes If you instead wish to separate the dependency protos from your source protos, you can make a separate directory for dependencies to be placed in and pass their directories to the Parameter documentation: https://ascopes.github.io/protobuf-maven-plugin/generate-mojo.html#importpaths I assume for this example you want Java rather than Golang output? FROM tools AS generated
RUN --mount=type=bind,target=github.com/moby/buildkit <<EOT
set -ex
mkdir /out
find github.com/moby/buildkit -name '*.proto' -o -name vendor -prune -false | xargs \
protoc --go_out=/out --go-grpc_out=require_unimplemented_servers=false:/out \
--go-vtproto_out=features=marshal+unmarshal+size+equal+pool+clone:/out
EOTIf so, something like the following should do what you want: <configuration>
<binaryMavenPlugins>
<!-- Generate gRPC stubs -->
<binaryMavenPlugin>
<groupId>io.grpc</groupId>
<artifactId>protoc-gen-grpc-java</artifactId>
<version>${grpc.version}</version>
<!-- Optional, but you can specify settings here. -->
<options>features=whatever+here</options>
</binaryMavenPlugin>
</binaryMavenPlugins>
<!-- Generate Java messages (this is the default, so you can usually omit this) -->
<javaEnabled>true</javaEnabled>
<sourceDirectories>
<!-- Assuming this dir exists prior to plugin invocation -->
<sourceDirectory>${project.basedir}/github.com/moby/buildkit</sourceDirectory>
<!-- Include this if you wish for the default input directory to still be used (this is the default if you do not specify sourceDirectories at all) -->
<sourceDirectory>${project.basedir}/src/main/protobuf</sourceDirectory>
</sourceDirectories>
<!-- Filter by the files you want to build rather than all files (all files is the default if includes and excludes are both empty) -->
<includes>
<!-- Syntax for this is the same as the Java NIO PathMatcher class for globs -->
<include>**/some_file_i_want.proto</include>
<include>vendor/**/*.proto</include>
</includes>
</configuration>Let me know if that helps! ETA: I've just promoted v3.1.2 to Maven Central which fixes a regression around how some of this includes/excludes mechanism works, so please make sure you are trying with that version of the plugin. Thanks. |
Beta Was this translation helpful? Give feedback.
Hey.
There is a pair of parameters
includesandexcludesthat take a list of glob patterns that should do what you need.Pass the directories of the sources into
sourceDirectories, then filter what you need usingincludesrelative to your source directories. That should achieve what you need.Example of the
includesparameter being used: https://github.com/ascopes/protobuf-maven-plugin/blob/main/protobuf-maven-plugin/src/it/gh-250-includes/pom.xml#L52Parameter documentation: https://ascopes.github.io/protobuf-maven-plugin/generate-mojo.html#includes
If you instead wish to separate the dependency protos from your source protos, you can make a separate directory for dependencies to be plac…