Protocol Buffers Compiler Maven Plug-In

5,771 views
Skip to first unread message

Tom

unread,
Jul 23, 2008, 10:05:18 AM7/23/08
to Protocol Buffers
Hi lads,

I've implemented a Maven 2 plug-in that invokes protoc (Protocol
Buffers Compiler) to generate Java classes. It hooks into build life
cycle at 'generate-sources' phrase. It scans specified directories to
find .proto files and invokes protoc executable to generate Java
classes into specified directory. Pretty useful stuff for all Maven
users, I guess.

I can contribute the source code to the main project if you are
interested. Otherwise I'll put in on Mojo (Codehaus) or create
separate project on Google Code. Please, lte me know if you are
interested in my contribution.

Cheers,
Tom

Kenton Varda

unread,
Jul 23, 2008, 4:41:41 PM7/23/08
to Tom, Gregory Kick, Protocol Buffers
Greg Kick (of Google) was also working on a Maven plugin.  Greg, what should we do?

Gregory Kick

unread,
Jul 23, 2008, 5:02:04 PM7/23/08
to Kenton Varda, Tom, Protocol Buffers, A list to discuss using Apache Maven to build and distribute java projects.
Tom,

As Kenton said, I'm working on a plugin to do much of the same work
and a bit more with regards to dependencies. I plan on having an
alpha version by the end of the week and would love some feedback. If
my implementation falls short, the next step would be to fill out the
contributor agreement [1] and we'll integrate the two implementations.

In any event, I'll send you an email as soon as something is publicly
available. Sound good?

[1] http://code.google.com/legal/individual-cla-v1.0.html

Tom

unread,
Jul 24, 2008, 3:36:24 AM7/24/08
to Protocol Buffers
Greg,

That's good news. I'm hoping to see your implementation soon. Can you
ping me as soon as your code is available, will you?
I'll also create separate project (open source) and check in my
implementation so then we can easier compare and integrate our efforts
if needed.

Take care,
Tom

On Jul 23, 10:02 pm, "Gregory Kick" <g...@google.com> wrote:
> Tom,
>
> As Kenton said, I'm working on a plugin to do much of the same work
> and a bit more with regards to dependencies.  I plan on having an
> alpha version by the end of the week and would love some feedback.  If
> my implementation falls short, the next step would be to fill out the
> contributor agreement [1] and we'll integrate the two implementations.
>
> In any event, I'll send you an email as soon as something is publicly
> available.  Sound good?
>
> [1]http://code.google.com/legal/individual-cla-v1.0.html
>
> On Wed, Jul 23, 2008 at 3:41 PM, Kenton Varda <ken...@google.com> wrote:
> > Greg Kick (of Google) was also working on a Maven plugin.  Greg, what should
> > we do?
>

Tom Nichols

unread,
Dec 3, 2008, 11:39:52 AM12/3/08
to Tom, prot...@googlegroups.com
Hi guys,

Has anything become of this? I'm looking for a protobuf compiler
Maven plugin and this is the only good lead I can find on the
intertubes.

Thanks.
-Tom

On Jul 24, 2:36 am, Tom <tomasz.blachow...@gmail.com> wrote:
> Greg,
>
> That's good news. I'm hoping to see your implementation soon. Can you
> ping me as soon as your code is available, will you?
> I'll also create separate project (open source) and check in my
> implementation so then we can easier compare and integrate our efforts
> if needed.
>
> Take care,
> Tom
>
> On Jul 23, 10:02 pm, "Gregory Kick" <g...@google.com> wrote:
>
> > Tom,
>

> > As Kenton said, I'm working on apluginto do much of the same work


> > and a bit more with regards to dependencies.  I plan on having an
> > alpha version by the end of the week and would love some feedback.  If
> > my implementation falls short, the next step would be to fill out the
> > contributor agreement [1] and we'll integrate the two implementations.
>
> > In any event, I'll send you an email as soon as something is publicly
> > available.  Sound good?
>
> > [1]http://code.google.com/legal/individual-cla-v1.0.html
>
> > On Wed, Jul 23, 2008 at 3:41 PM, Kenton Varda <ken...@google.com> wrote:

> > > Greg Kick (of Google) was also working on aMavenplugin.  Greg, what should


> > > we do?
>
> > > On Wed, Jul 23, 2008 at 7:05 AM, Tom <tomasz.blachow...@gmail.com> wrote:
>
> > >> Hi lads,
>

> > >> I've implemented aMaven2 plug-in that invokes protoc (Protocol

Kenton Varda

unread,
Dec 3, 2008, 3:59:55 PM12/3/08
to Tom Nichols, Gregory Kick, Tom, prot...@googlegroups.com
[cc Gregory]

Gregory Kick

unread,
Dec 3, 2008, 4:02:03 PM12/3/08
to Kenton Varda, Tom Nichols, Tom, prot...@googlegroups.com
The intertubes have led you to the right place. This has actually
been done for a while, but I haven't written the tests (arg!). I'll
definitely get it checked in by the end of the year. Sorry for the
procrastination.

Tom Nichols

unread,
Dec 4, 2008, 12:57:13 PM12/4/08
to Gregory Kick, Kenton Varda, Tom, prot...@googlegroups.com
Thanks Greg, Kent --

No problem. Actually if you can stick a build in the Maven repo that
would be super cool too. Then using the plugin would be a simple
matter of a few lines in a POM.

Gregory Kick

unread,
Dec 4, 2008, 2:04:44 PM12/4/08
to Tom Nichols, Kenton Varda, Tom, prot...@googlegroups.com
That's the plan.

cl...@computer.org

unread,
Dec 8, 2008, 5:17:35 PM12/8/08
to Protocol Buffers
This would indeed be quite useful!

On Dec 4, 11:04 am, Gregory Kick <g...@google.com> wrote:
> That's the plan.
>
> On Thu, Dec 4, 2008 at 11:57 AM, Tom Nichols <tmnich...@gmail.com> wrote:
> > Thanks Greg, Kent --
>
> > No problem.  Actually if you can stick a build in the Maven repo that
> > would be super cool too.  Then using the plugin would be a simple
> > matter of a few lines in a POM.
>
> > On Wed, Dec 3, 2008 at 4:02 PM, Gregory Kick <g...@google.com> wrote:
> >> The intertubes have led you to the right place.  This has actually
> >> been done for a while, but I haven't written the tests (arg!).  I'll
> >> definitely get it checked in by the end of the year.  Sorry for the
> >> procrastination.
>
> >> On Wed, Dec 3, 2008 at 2:59 PM, Kenton Varda <ken...@google.com> wrote:
> >>> [cc Gregory]
>

David Biesack

unread,
Jan 12, 2009, 10:58:21 AM1/12/09
to Protocol Buffers
Is this available yet?

If not, can someone post how to invoke protoc from a more "vanilla"
Java Maven project to generate .java source, using explicit paths or
whatever it takes. I'm a little familiar with Maven, but mostly via
using existing plugins, not adding callouts.

TIA,
djb

On Dec 3 2008, 4:02 pm, Gregory Kick <g...@google.com> wrote:
> The intertubes have led you to the right place.  This has actually
> been done for a while, but I haven't written the tests (arg!).  I'll
> definitely get it checked in by the end of the year.  Sorry for the
> procrastination.
>
> On Wed, Dec 3, 2008 at 2:59 PM, Kenton Varda <ken...@google.com> wrote:
> > [cc Gregory]
>
> > On Wed, Dec 3, 2008 at 8:39 AM, Tom Nichols <tmnich...@gmail.com> wrote:
>
> >> Hi guys,
>
> >> Has anything become of this?  I'm looking for a protobuf compiler
> >>Mavenplugin and this is the only good lead I can find on the

Nat

unread,
Jan 15, 2009, 5:03:30 PM1/15/09
to Protocol Buffers
I am also looking for this plugin to be complete (I was thinking of
writing one myself), but here's an example to get you going until it's
finished. I created a directory src/main/protobuf in my maven project
and put a single "test.proto" file in there, and added this to my
pom.xml:

--- snip ---

<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<tasks>
<mkdir dir="target/generated-sources"/>
<exec executable="protoc">
<arg value="--java_out=target/
generated-sources"/>
<arg value="src/main/protobuf/
test.proto"/>
</exec>
</tasks>
<sourceRoot>target/generated-sources</
sourceRoot>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>

--- snip ---

This is entirely lifted from the contents of pom.xml for protobuf
2.0.3 in the central maven repo with only slight modification, and it
works Ok for me for this simple project. To make things easier with
my IDE I will likely have a protobuf-only project, then make my
program logic just use that as a dependency.

Hope that helps until this plugin can be finished.

N

Nat

unread,
Jan 20, 2009, 12:35:26 PM1/20/09
to Protocol Buffers
So is this going anywhere? Bueller...? Bueller...?

After my last post I was curious to build my first Maven2 plugin, and
I also now have a working plugin that binds to the generate-sources
phase like Tom's original post in this thread. I was just about to
(ask to) put it on Codehaus but re-read this thread first and realized
Tom is already in position to do so, so I'll hold off. However, it
seems like if this is going to be further delayed maybe it makes sense
to pursue this option. Gregory, I'm sure you are a busy man but do
you have an estimate of when you think you might be able to publish
this? Or do you think it's a good idea for either myself or Tom to
post to Codehaus/elsewhere in the meantime?

Nat

Kenton Varda

unread,
Jan 20, 2009, 1:54:41 PM1/20/09
to Nat, Gregory Kick, Protocol Buffers
[cc Greg to get his attention]

Gregory Kick

unread,
Jan 20, 2009, 2:12:21 PM1/20/09
to Kenton Varda, Nat, Protocol Buffers
I totally understand the frustration. This had slipped to the bottom
of the priorities, but I'm actually working on this stuff today.
Basically, my plan is to check in the plugin today. The plugin is
more or less done, but I have no tests. (ack!) I would really,
really, really appreciate it if somebody could contribute some. As
soon as I check in the plugin everybody that expressed interest will
get a notice about a code review.

Sorry again for the slacking.

Nathaniel Harward

unread,
Jan 20, 2009, 3:15:23 PM1/20/09
to Gregory Kick, Kenton Varda, Protocol Buffers
I don't really consider this slacking; anything going to the open source community is a public gift and should be treated as such.  I mostly just want to avoid fragmentation and having three different plugins doing the same thing, so that it can be focused and as high-quality as possible.  Even if it has no tests I'd love to see it as an alpha-release plugin, and perhaps Tom, myself and others can help out with tests and/or enhancements to bring it to beta and/or release.

As I said I made one for internal use at my workplace and it will satisfy our needs until this one pops up.  Thanks in advance to you and Tom (and anyone else working on it); I'd love to see protobuf gain in popularity and tooling and in particular replace XML where it makes sense (which is a LOT of places); I just can't take any more inappropriate use of XML in my life :)

Nat

Brian Erst

unread,
Feb 2, 2009, 11:40:20 AM2/2/09
to Protocol Buffers
Any update on the Maven plug-in? We've had two different plug-ins that
have essentially been abandoned waiting for an imminent Google release
for six months now. I've used various hacks to the POM files, but a
real plug-in would be sweet.

Kenton Varda

unread,
Feb 2, 2009, 12:55:23 PM2/2/09
to Brian Erst, Gregory Kick, Protocol Buffers
Gregory, could you please at least check in your code to SVN?

Gregory Kick

unread,
Feb 2, 2009, 1:10:18 PM2/2/09
to Kenton Varda, Brian Erst, Protocol Buffers
Definitely. Now that I have access this will be done this week.

SilentJ

unread,
Mar 18, 2009, 8:03:24 AM3/18/09
to Protocol Buffers
Just in case others are looking for it, the maven plugin has been
checked in to svn:

http://code.google.com/p/protobuf/source/browse/

You can find it at: branches/maven-plugin/tools/maven-plugin

I haven't used it but will be trying it out soon.

Sverre Moe

unread,
Sep 12, 2014, 7:30:49 AM9/12/14
to prot...@googlegroups.com, ken...@google.com, brian...@gmail.com
I cannot find any Google Protobuf Maven Plugin in the Central Maven Repository under com.google.protobuf

Peter Ondruška

unread,
Sep 12, 2014, 7:57:24 AM9/12/14
to prot...@googlegroups.com, ken...@google.com, brian...@gmail.com
I can find it but the latest version is 2.5.0 :-(
Reply all
Reply to author
Forward
0 new messages