Reputation:
I have a lot of .proto
files and I am using maven-antrun-plugin
to generate the necessary Java files. It works as long as I specifically write each and every .proto
file, like this:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<mkdir dir="target/src-gen"/>
<exec executable="protoc">
<arg value="--java_out=target/src-gen"/>
<arg value="target/proto/Empty.proto"/>
<arg value="target/proto/ComponentState.proto"/>
</exec>
</tasks>
<sourceRoot>target/src-gen</sourceRoot>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
This already works fine.
However, now that I get more .proto files (around 30), I cannot use the above method, since I'd have to write it one by one, and I don't think this is the appropriate way of doing it.
Is there a shortcut for this? To say "compile all .proto
files under this directory and its subdirectories." would be very nice.
Anyone has an idea?
Upvotes: 1
Views: 873
Reputation: 21
The following snippet works for me.
<configuration>
<target>
...
<path id="protobuf.input.filepaths.path">
<fileset dir="${protobuf.input.directory}">
<include name="**/*.proto"/>
</fileset>
</path>
...
</target>
</configuration>
Upvotes: 2