<!-- protobuf-java for maven plugin
http://stackoverflow.com/questions/1578456/integrate-protocol-buffers-into-maven2-build
Execute failed: java.io.IOException: Cannot run program "protoc":
complile and install compiler the protoc:
# git clone https://github.com/google/protobuf
# ./autogen.sh
# ./configure
# make && make check
# sudo make install
After all, compile a proto to java (== means two minus signs):
# protoc -I=$SRC_DIR ==java_out=$DST_DIR user.proto
-->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<mkdir dir="src/main/java/avro/channel/protobuf"/>
<exec failοnerrοr="true" executable="protoc">
<arg value="--java_out=src/main/java/avro/channel/protobuf"/>
<arg value="src/avro/user.proto"/>
</exec>
</tasks>
<sourceRoot>src/main/java/avro/channel/protobuf</sourceRoot>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protobuf-java.version}</version>
</dependency>
</dependencies>
option java_package = "avro.channel.protobuf";
option java_outer_classname = "Reg";
message User {
required string ipaddr = 1;
optional string cookie = 2;
optional int64 token = 3;
}
https://github.com/google/protobuf/releases
$ wget --no-check-certificate https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
$ tar -zxf protobuf-2.6.1.tar.gz
$ cd protobuf-2.6.1/
$ ./configure
$ make check
sudo make install
$ sudo cd /etc/ld.so.conf.d/
$ sudo touch libprotobuf.conf
$ sudo echo "/usr/local/lib" >> libprotobuf.conf
$ sudo ldconfig
$ protoc --version
libprotoc 2.6.1