- 1 year ago
How to solve CreateProcess error=206, The filename or extension is too long error of maven-protobuf-plugin?
The "CreateProcess error=206, The filename or extension is too long" error in the maven-protobuf-plugin can occur when the plugin is trying to execute a command that exceeds the maximum allowed length of a command-line string in Windows.
To solve this error, you can try one or more of the following solutions:
Shorten the path of your project or the location of your protobuf files. This can help reduce the length of the command-line string used by the plugin.
Use a plugin configuration option to skip generating certain files. For example, you can use the
skip
option to skip generating Java source files, as shown below:php<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
Use a plugin configuration option to split the command into multiple commands. For example, you can use the
command
option to split theprotoc
command into multiple commands, as shown below:php<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<command>
<os>
<windows>protoc.exe</windows>
<linux>protoc</linux>
</os>
<arguments>
<argument>-I=${basedir}/src/main/proto</argument>
<argument>--java_out=${project.build.directory}/generated-sources/java</argument>
<argument>--plugin=protoc-gen-grpc-java=%GRPC_JAVA_PLUGIN%</argument>
<argument>--grpc-java_out=${project.build.directory}/generated-sources/grpc-java</argument>
<argument>${basedir}/src/main/proto/*.proto</argument>
</arguments>
</command>
</configuration>
</plugin>
Use a plugin configuration option to specify a custom output directory. For example, you can use the
outputDirectory
option to specify a custom directory for the generated files, as shown below:php<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
</configuration>
</plugin>
By using one or more of these solutions, you should be able to solve the "CreateProcess error=206, The filename or extension is too long" error in the maven-protobuf-plugin.