Samstag, 16. August 2008
Ant task for ProtocolBuffers
ProtocolBuffers (pb)are an interesting new protocol. Till recently it was a proprietary protocol. So it was no surprise, that there were only limited support for usual development tools available. I wrote recently an eclipse plugin for syntax highlighting. I am using pb for a messaging project and I needed therefore some ant-build support. If you have read some of my previous blogs, you know that a reliable build is as important as a reliable configuration management process. So I decided to write an ant-task for pb.
If you are interested you can now download it here and the source here. This version is released under Apache License, Version 2.0

You can use it with an ant target like:

<target name="compile_proto" >
<taskdef name="pb" classname= "org.schmidmeier.protocolbuffer.ant.PbTask" 

<pb ProtoFile="Sample.proto" ipath="/prj/pbuffer/include" 
   <protopathentry ipath="proto_includes "/>
   <protopathentry ipath="protolibs "/> 
At first you have to define the task. You do it with the taskdef statement. From here on you can use the pb task. ipath defines the includefiles. java, cpp, and python define for which languages code should be generated. (and where it should be dropped)

Here are the possible attributes for the task.


Attribute Description Required
java if set, output will be generated for java. The value must be the java output directory at least on of java, python, cpp
cpp if set, output will be generated for C++. The value must be the C++ output directory at least on of java, python, cpp
python if set, output will be generated for python. The value must be the python output directory at least on of java, python, cpp
ipath The directory which may contain include files No, default unset
failonerror if set, the compilation aborts in case of errors No, Default, true
protopathentry The possibility to add multiple include file to the command line No, Required unset

Current open issues:

  1. The ant-job was currently only tested on windows. If you find some issues on other platform, please notify me
  2. The pb-compiler which is invoked from the ant-job has some problems with Windows drive names, when it should generate C++ or python code.
If you have some comments, have found some bugs, etc. please feel free to contact me on pb at Schmidmeier dot org

... comment