The B.proto needs to be packaged into a jar file and listed as a dependency 
in your project. In that case the maven-protoc-plugin will do as stated in 
the documentation:

The Plugin automatically scans all project dependencies for bundled .proto 
> files, and configures proto_path of the Protocol Buffer Compiler to use 
> those files as imports.


So if you start with a maven module with one file, and the appropriate 
pom.xml with maven-protoc-plugin configured
it will produce 'B.jar' which you can reference as a dependency from A's 


Paul Nyheim

On Wednesday, May 15, 2013 12:30:16 PM UTC+2, Safi Ali wrote:
> Hi,
> I am using maven-protoc-plugin version 0.3.1 to compile my protoc 
> definations. Protoc version is 2.5.0.
> I am having trouble adding the --proto_path in my maven protoc plugin 
> configuration (in pom.xml).
> I have a protoc file (say A.protoc) which imports another protoc file (say 
> B.protoc) from a different directory.
> I can compile A.protoc from command line using protoc, if I mention the 
> path to B.protoc in the --proto_path argument. For example:-
> protoc --java_out=. --proto_path='/path/to/imported_protoc_files:.' A.proto
> This gives me the java output.
> But when I build using maven plugin, it cant seem to find the imported 
> file (B.protoc). I have been trying to different ways to specify the 
> --proto_path but I havent figured out how to add that to my pom.xml 
> configuration. 
> I get this output when I try to build from maven:-
> [INFO] --- maven-protoc-plugin:0.3.1:compile (default) @ tac-api ---
> [INFO] Compiling 5 proto file(s) to /my/output/path
> [ERROR] protoc failed output: 
> [ERROR] protoc failed error: B.proto: File not found.
> A.proto: Import "B.proto" was not found or had errors.
> A.proto:23:12: "types.Cell" is not defined.
> And this is my pom.xml protoc configuration:-
>                       <plugin>
>     <groupId></groupId>
>     <artifactId>maven-protoc-plugin</artifactId>
>     <version>0.3.1</version>
>     <configuration>
>         <protocExecutable>protoc</protocExecutable>
>  <protoSourceRoot>${project.basedir}/src/test/resources/</protoSourceRoot>
>         <languageSpecifications>
>             <LanguageSpecification>
>                <language>JAVA</language>
>                <outputDirectory>
>                     ${project.basedir}/target/generated-sources/java
>                </outputDirectory>
>             </LanguageSpecification>
>         </languageSpecifications>                     
>     </configuration>
>                             <executions>
>         <execution>
>             <goals>
>                 <goal>compile</goal>
>             </goals>
>         </execution>
>     </executions>
> </plugin>
> I have tried to search different forums but didnt find any clear 
> instructions of how to get around this in pom.xml. Can some point me in the 
> right direction?
> Regards,
> Safi

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to