user01 user01 - 1 month ago 13
Java Question

Protocol buffers compiler maven plugin

I have protocol buffers compiler plugin configured in my POM that is executed whenever the project is built. This complier plugin works fine in windows but now I moved my project to an ubuntu PC & need to used a suitable alterntive for this.

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compile-protoc</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<mkdir dir="src/main/resources/protocolBuffers/compiled" />
<path id="proto.path">
<fileset dir="src/main/proto">
<include name="**/*.proto" />
</fileset>
</path>
<pathconvert pathsep=" " property="proto.files" refid="proto.path" />
<exec executable="src/main/resources/protocolBuffers/compiler/protoc" failonerror="true">
<arg value="--java_out=src/main/resources/" />
<arg value="-I${project.basedir}/" />
<arg line="${proto.files}"/>
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>


I see the following output when trying to build the project in Ubuntu netbeans

--- maven-antrun-plugin:1.3:run (compile-protoc) @ Px10App ---
Executing tasks
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 5.638s
Finished at: Tue Mar 25
Final Memory: 9M/105M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (compile-protoc) on project Px10App: An Ant BuildException has occured: Execute failed: java.io.IOException: Cannot run program "src/main/resources/protocolBuffers/compiler/protoc": error=2, No such file or directory -> [Help 1]


How to make compiler plugin work in Ubuntu netbeans ?

Answer

Your protoc executable could not be executed on linux. You should download and compile protoc for linux and once you do it you will be able to use this maven plug-in as you are using it on windows.

You have detailed instruction for this here

Comments