The maven-protobuff project contains a lightweight maven plugin used to compile proto files.
- Will automatically extract .proto files out of dependency jars and put them into “//target/protos”.
- Will compile your module/project proto files into the “//src/main/java” directory for checkin.
- Works with both standard and multi-module projects.
- "clear" - true by default, will delete the temp //target/protos directory before running.
- "verbose" - false by default, will output additional information, including the protoc command parameters.
- "protoc" - "protoc" by default, the protoc executable to use. The default value assumes you have the protoc executable on your path.
- "protoSources" / "protoSource" - A list of proto files in your project to be compiled.
- "includePaths" / "includePath" - A list of paths to add to the protoc include path list. If not specified will default to "src/main/resources" and, if there were dependencies with proto files, "target/protos/" and "target/protos/protobuf".
To use it, simply execute the “proto:compile” target like so:
$ mvn maven-protobuff:compile
In the following usage example, the "protobuf-build" profile is used to selectively build proto files.
<profiles>
<profile>
<id>protobuf-build</id>
<build>
<plugins>
<plugin>
<groupId>com.blizzard</groupId>
<artifactId>maven-protobuff</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<verbose>true</verbose>
<protoSources>
<protoSource>src/main/resources/com/blizzard/nexus/nexus.proto</protoSource>
</protoSources>
</configuration>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
Copyright (c) 2012 Blizzard Entertainment
Open sourced under the MIT license. See the included LICENSE file for more information.