xolstice / protobuf-maven-plugin

Maven Plugin that executes the Protocol Buffers (protoc) compiler
https://www.xolstice.org/protobuf-maven-plugin/
Other
232 stars 76 forks source link

Too many .proto lead to "CreateProcess error=206, The filename or extension is too long" on Windows #5

Closed sannies closed 6 years ago

sannies commented 8 years ago

I'm working on a project with 306 proto files. That makes the command line longer than windows allows:

[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.5.0:compile (generate-java-classes-for-generated-protos) on project *******-server: An error occurred while invoking protoc. Error while executing process. Cannot run program "C:\dev\server\******-server\target\protoc-plugins\protoc-2.6.1-windows-x86_64.exe": CreateProcess error=206, The filename or extension is too long -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.5.0:compile (generate-java-classes-for-generated-protos) on project *******-server: An error occurred while invoking protoc.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: org.apache.maven.plugin.MojoExecutionException: An error occurred while invoking protoc.
    at org.xolstice.maven.plugin.protobuf.AbstractProtocMojo.execute(AbstractProtocMojo.java:551)
    at org.xolstice.maven.plugin.protobuf.AbstractProtocCompileMojo.execute(AbstractProtocCompileMojo.java:31)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 25 more
Caused by: org.codehaus.plexus.util.cli.CommandLineException: Error while executing process.
    at org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:675)
    at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLineAsCallable(CommandLineUtils.java:134)
    at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:105)
    at org.codehaus.plexus.util.cli.CommandLineUtils.executeCommandLine(CommandLineUtils.java:88)
    at org.xolstice.maven.plugin.protobuf.Protoc.execute(Protoc.java:184)
    at org.xolstice.maven.plugin.protobuf.AbstractProtocMojo.execute(AbstractProtocMojo.java:529)
    ... 28 more
Caused by: java.io.IOException: Cannot run program "C:\dev\server\******-server\target\protoc-plugins\protoc-2.6.1-windows-x86_64.exe": CreateProcess error=206, The filename or extension is too long
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at java.lang.Runtime.exec(Runtime.java:620)
    at org.codehaus.plexus.util.cli.Commandline.execute(Commandline.java:655)
    ... 33 more
Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
    at java.lang.ProcessImpl.start(ProcessImpl.java:137)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 35 more
[ERROR] 
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

I do of course know that this is a Windows restriction but perhaps you can think of a workaround.

sergei-ivanov commented 8 years ago

Hello @sannies,

This has been a constant source of pain and frustration on Windows, and there's no universal workaround at the moment. However, I suspect that passing 306 source proto files on the command line may bust the limits of even more robust operating systems.

You can try voting for google/protobuf#274 -- if they implement it in the same way that javac accepts command line parameters, then life will become so much easier.

I had some ideas of how I could attack it from the maven plugin's perspective, but nothing's planned for the nearest future. I think I'll try to sort it out together with configuration rewrite, because the current implementation does not leave much room for manoeuvre.

If you can split your protos into several smaller groups, then you'll be able to divide and conquer the compilation. You can either split them into several (possibly interdependent) maven modules, or you can split your plugin execution into a number of smaller executions, each compiling a subset of sources (controlled by the include/exclude parameters on each execution).

Kind regards, Sergei

fostersanders commented 7 years ago

Hello,

I had the same problem. I didn´t know what to do so I searched on the internet for some solutions.

And I read about [b]Long Path Tool[/b], which is a great tool in these type of cases. :o

It worked really well. Hope it works for you too :p

onderson commented 6 years ago

@fostersanders , i wonder how you used Long Path Tool. I have seen couple of people saying the same but have not come across any example. if you could share one. that would be helpful. thanks

Spatzier-Beck commented 5 years ago

Hello,

is it planned to deploy the new version (0.6.0) to the maven repository (https://mvnrepository.com/artifact/org.xolstice.maven.plugins/protobuf-maven-plugin)?

Why hasn't it been deployed yet? Is there any known issue? It would help us a lot if the version 0.6.0 was available on the maven repository.

Thanks a lot.

Best regards Rainer

sergei-ivanov commented 5 years ago

@Spatzier-Beck Sorry for the delay. I wanted to fix some other issues as well and add some documentation, but I hope to release the new version in the next few days.

sergei-ivanov commented 5 years ago

Release 0.6.1 has just been pushed, but it may take some time until it is fully synced to Maven Central. When it is available, please give it a go and let me know if it works for you.

Spatzier-Beck commented 5 years ago

@sergei-ivanov Yesterday I integrated the new version 0.6.1 into our build and it works very well. It is not yet visible in the Maven Central Repository Homepage, but it is already available and can be used in maven builds. Thanks a lot for your help :-)

sergei-ivanov commented 5 years ago

You are very welcome. Looks like Maven Central has been re-indexed and finally the artifacts can be seen on the search page too.

yinzara commented 2 years ago

In case any missed it and were confused, to fix this issue, upgrade protobuf-maven-plugin to 0.6.1 and set the < useArgumentFile>true</useArgumentFile> configuration option in the plugin