Issue 152 in protobuf: Maven Protoc Plugin fails when a jar file contains a .proto file (FileNotFoundException)

305 views
Skip to first unread message

prot...@googlecode.com

unread,
Jan 11, 2010, 1:00:43 PM1/11/10
to prot...@googlegroups.com
Status: New
Owner: ken...@google.com
Labels: Type-Defect Priority-Medium

New issue 152 by rktoomey: Maven Protoc Plugin fails when a jar file
contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

What steps will reproduce the problem?
This repro is the same as in Issue 138
(http://code.google.com/p/protobuf/issues/detail?id=138)
1. Build project (A) so the that .proto file is embedded in the jar file.
2. Create project (B) that also has a .proto file.
3. Add (A) as a dependency of (B)
4. In project (B) Try to: mvn -X clean install

What is the expected output? What do you see instead?

I expect a successful build instead I get:

[INFO] [protoc:compile {execution: generate-sources}]
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] An IO error occured

Embedded error:
c:\projectB\target\protobuf-temp\C:\m2\repository\projectA\1.2.0-SNAPSHOT\projectA-1.2.0-SNAPSHOT.jar\projectA_messages.proto
(The filename, directory name, or volume label syntax is incorrect)
[INFO]
------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: An IO error occured
at
<SNIP>

Caused by: org.apache.maven.plugin.MojoExecutionException: An IO error
occured
at
com.google.protobuf.maven.AbstractProtocMojo.execute(AbstractProtocMojo.java:125)
at
com.google.protobuf.maven.ProtocCompileMojo.execute(ProtocCompileMojo.java:22)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: java.io.FileNotFoundException:
c:\projectB\target\protobuf-temp\C:\m2\repository\projectA\1.2.0-SNAPSHOT\projectA-1.2.0-SNAPSHOT.jar\projectA_messages.proto
(The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at
org.codehaus.plexus.util.FileUtils.copyStreamToFile(FileUtils.java:1058)
at
com.google.protobuf.maven.AbstractProtocMojo.makeProtopathFromJars(AbstractProtocMojo.java:211)
at
com.google.protobuf.maven.AbstractProtocMojo.execute(AbstractProtocMojo.java:104)
... 20 more

What version of the product are you using? On what operating system?
maven-protoc-plugin 0.1.2
maven 2.2.1
java 1.6.0_17
OS is Windows 7, typically I use Cygwin.

Please provide any additional information below.

Project A is a jar file in my local Maven repository which contains
projectA_messages.proto.

Project B depends on the jar file for Project A.

It looks like maven-protoc-plugin finds the jar file in the dependencies
and falls down trying to extract the .proto file.

Possibly related to http://code.google.com/p/protobuf/issues/detail?id=138?

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

prot...@googlecode.com

unread,
Jan 11, 2010, 1:04:47 PM1/11/10
to prot...@googlegroups.com

Comment #1 on issue 152 by rktoomey: Maven Protoc Plugin fails when a jar
file contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

I am using protobuf-java 2.2.0, defined in the parent pom dependencies for
both
project A and project B.

prot...@googlecode.com

unread,
Jan 11, 2010, 1:17:53 PM1/11/10
to prot...@googlegroups.com

Comment #2 on issue 152 by rktoomey: Maven Protoc Plugin fails when a jar
file contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

The problem is that AbstractProtocMojo.makeProtopathFromJars is
constructing a
non-viable Windows path for the file:


c:\projectB\target\protobuf-temp\C:\m2\repository\projectA\1.2.0-SNAPSHOT\projectA-1.2.0-SNAPSHOT.jar\projectA_messages.proto

This seems to be a Windows-specific issue, as it would be fine under *nix
where the
path would be viable, something like:
/home/user/projectB/target/protobuf-temp/home/user/.m2/repository/projectA/1.2.0-SNAPSHOT/projectA-1.2.0-SNAPSHOT.jar/projectA_messages.proto

prot...@googlecode.com

unread,
Jan 11, 2010, 1:40:16 PM1/11/10
to prot...@googlegroups.com
Updates:
Owner: gk5885

Comment #3 on issue 152 by ken...@google.com: Maven Protoc Plugin fails

when a jar file contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

(No comment was entered for this change.)

prot...@googlecode.com

unread,
Jan 11, 2010, 2:52:01 PM1/11/10
to prot...@googlegroups.com

Comment #4 on issue 152 by rktoomey: Maven Protoc Plugin fails when a jar
file contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

Confirmed working on Linux (Ubuntu 9.10), so this is a(n annoying)
Windows-only bug.
But it's a blocker for our project, so we'll try to patch the plugin code
so we can
continue using maven-protoc-plugin.

prot...@googlecode.com

unread,
Jan 11, 2010, 10:02:12 PM1/11/10
to prot...@googlegroups.com

Comment #5 on issue 152 by rktoomey: Maven Protoc Plugin fails when a jar
file contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

The stupidest thing that could possibly work - edit
AbstractProtocMojo.makeProtopathFromJars method to produce a viable Windows
filepath
by replacing all occurrences of ":" in the classpathJarName with "_" as
follows:

ImmutableSet<File> makeProtopathFromJars(
File temporaryProtoFileDirectory, Iterable<File> classpathElementFiles)
throws IOException
{
<SNIP>
for (JarEntry jarEntry : list(classpathJar.entries()))
{
final String jarEntryName = jarEntry.getName();
if (jarEntry.getName().endsWith(PROTO_FILE_SUFFIX))
{
String sanitizedClasspathJarName =
classpathJar.getName().replace(":", "_");
final File uncompressedCopy = new File(new
File(temporaryProtoFileDirectory,
sanitizedClasspathJarName), jarEntryName);
uncompressedCopy.getParentFile().mkdirs();
copyStreamToFile(new
RawInputStreamFacade(classpathJar.getInputStream(jarEntry)),
uncompressedCopy);
protoDirectories.add(uncompressedCopy.getParentFile());
}
}
<SNIP>

prot...@googlecode.com

unread,
Jan 13, 2011, 2:44:38 PM1/13/11
to prot...@googlegroups.com

Comment #6 on issue 152 by panwar007: Maven Protoc Plugin fails when a jar
file contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

Hello everyone,

I am building my project on Windows and facing the same issue. I am not
sure where to make the modification suggested by "rktoo" .

Has this issue been resolved?

prot...@googlecode.com

unread,
Jan 18, 2011, 11:30:52 PM1/18/11
to prot...@googlegroups.com

Comment #7 on issue 152 by ken...@google.com: Maven Protoc Plugin fails
when a jar file contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

AFAICT, Greg has abandoned the Maven plugin code. We don't seem to have a
use for it at Google, so it's unlikely that anyone here will pick it up.
If someone would like to fork this code as a new Google Code project,
please feel free. (It should probably have been a separate project all
along anyway.)

prot...@googlecode.com

unread,
Jan 26, 2011, 3:25:08 PM1/26/11
to prot...@googlegroups.com
Updates:
Owner: g...@google.com
Blockedon: 81

Comment #8 on issue 152 by g...@google.com: Maven Protoc Plugin fails when

a jar file contains a .proto file (FileNotFoundException)
http://code.google.com/p/protobuf/issues/detail?id=152

As I mentioned in issue 81, I didn't intentionally abandon the plugin, just
the account that was receiving emails for these issues. :-/ Sorry
everybody.

Anyway, take a look at 81 for the discussion on whether or not to move
forward with this plugin or just deprecate it in favor of a fork that seems
to be actively developed.

Reply all
Reply to author
Forward
0 new messages