Comment #17 on issue 81 by walker.zach: Maven Protoc Plugin Code Review
http://code.google.com/p/protobuf/issues/detail?id=81

I think my comment is similar to the issues raised by comments 5 and 15.

I attempted to use the plugin to generate code from a .proto file that imported
messages from an external .proto file.  First, I attempted to add a jar file
containing both the depended on .proto and the java classes generated from it to the
dependency list in my pom file.  I would then get the error message.

org.apache.maven.BuildFailureException: Protoc failed to execute because: null
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:699)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:540)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:519)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:356)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoFailureException: Protoc failed to execute
because: null
        at
com.google.protobuf.maven.AbstractProtocMojo.execute(AbstractProtocMojo.java:127)
at com.google.protobuf.maven.ProtocCompileMojo.execute(ProtocCompileMojo.java:22)
        at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
        ... 16 more
Caused by: java.lang.IllegalArgumentException
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:70) at com.google.protobuf.maven.Protoc$Builder.addProtopathElement(Protoc.java:178) at com.google.protobuf.maven.Protoc$Builder.addProtopathElements(Protoc.java:188)
        at
com.google.protobuf.maven.AbstractProtocMojo.execute(AbstractProtocMojo.java:109)
        ... 19 more


I'm not sure exactly what the problem was but I could tell that it was related to the plugin attempting to resolve the compile dependency on the jar with the .proto and generated classes. I took a look at the source and found that the plugin's comile goal is linked to the compile time dependencies in the pom file. I couldn't figure out why the protoc compiler would need any dependency resources, so I removed the @requiresDependencyResolution annotation from ProtocCompileMojo.java and rebuilt the
plugin.  The error then went away.

It would be nice if a the .proto file compiled by the plugin could import another
.proto file from a jar in the pom dependencies.

--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to