CreateProcess error = 206, The filename or extension is too long "solution, filenametoolong
In actual projects, I use antrun and closure-compiler to compress JS projects. Then I will use the following code: First add the dependency.
<dependency> <groupId>com.google.javascript</groupId> <artifactId>closure-compiler</artifactId> <version>v20160315</version></dependency>
Add the pom. xml file to the plug-in code.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <property name="closure.compiler.class.name" value="com.google.javascript.jscomp.CommandLineRunner" /> <echo message="Generate main.min.js" /> <java classname="${closure.compiler.class.name}" classpathref="maven.compile.classpath" fork="true" failonerror="true"> <arg value="--js"/> <arg value="${basedir}/src/main/webapp/js/main.js"/> <arg value="--js_output_file"/> <arg value="${basedir}/src/main/webapp/js/main.min.js" /> <arg value="--compilation_level"/> <arg value="SIMPLE_OPTIMIZATIONS"/> </java> </target> </configuration> </execution> </executions> </plugin>
Then an error is reported during running. CreateProcess error = 206, too many errors have occurred» wait) When zookeeper was found and there was a pile of garbled characters behind it. After searching through stackoverflow, it was found that the garbled code was probably "CreateProcess error = 206,The filename or extension is too long"
"There are limits on the length of strings supported by the command line in Windows. on a computer, run Microsoft Windows XP or a later version, the maximum length of a string that can be used in a command prompt is 8191 characters. On a computer running Microsoft Windows 2000 or Windows NT 4.0, the maximum length of a string that can be used at a command prompt is 2047 characters."
I also don't understand why my antrun command is too long and there are so few arg parameters above. Then I use mvn package-X to print the details. Classpathref = "maven. compile. classpath" is found, and all lib jar packages are printed to run the command.
Instead of specifying the jar package closure-complie to run.
Know In maven that you can directly specify the maven dependency's closure-complie.jar package, refer to the following address:
Http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html
So modify the above pom. xml code:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>run</goal> </goals> <configuration> <target> <property name="closure.compiler.class.name"value="com.google.javascript.jscomp.CommandLineRunner" /> <echo message="Generate main.min.js" /> <path id="maven.lib.dep" path="${com.google.javascript:closure-compiler:jar}"/> <java classname="${closure.compiler.class.name}" classpathref="maven.lib.dep" fork="true" failonerror="true"> <arg value="--js"/> <arg value="${basedir}/src/main/webapp/js/main.js"/> <arg value="--js_output_file"/> <arg value="${basedir}/src/main/webapp/js/main.min.js" /> <arg value="--compilation_level"/> <arg value="SIMPLE_OPTIMIZATIONS"/> </java> </target> </configuration> </execution> </executions> </plugin>
Specify the classpathref Parameter