![](/img/trans.png)
[英]CreateProcess error=206, The filename or extension is too long when running gwtCompile
[英]When executing proguard-maven-plugin, "CreateProcess error=206, The filename or extension is too long" occurs
我们正在开发我们自己的 Eclipse 插件 jars,供我们基于 Eclipse 的应用程序使用。 我们目前正在使用proguard-maven-plugin
版本 2.0.8 来混淆它们。 但是,在某些插件上运行mvn install
时,我们目前遇到以下错误:
[INFO] ---------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ---------------------------------------------------------------------
[INFO] Total time: 1:34.297s
[INFO] Finished at: Tue Apr 21 16:03:51 SGT 2015
[INFO] Final Memory: 88M/210M
[INFO] ---------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.0.8:proguard (default) on project com.x.y: Execution default of goal com.github.wvengen:proguard-maven-plugin:2.0.8:proguard failed: java.io.IOException: Cannot run program "C:\Program Files (x86)\Java\jdk1.7.0_55\jre\bin\java.exe": CreateProcess error=206, The filename or extension is too long -> [Help 1]
有没有人遇到过这个? 如果是这样,您是如何解决问题的?
请注意,在决定提问之前,我实际上已经看过这个问题和其他相关问题,但 Brad Mace 的答案不适用于我的情况,因为 Proguard 生成了“CreateProcess error=206,文件名或扩展名太长”而不是由 Javadoc 提供。 最初,我认为(如果我错了,请纠正我)espinchi 给出的 7 个选项中的一个或它们的变体可能会起作用,但我不确定是哪一个。 只是为了让您知道我在确定解决方案时的限制:
作为参考,下面是我的 pom 文件中与 Proguard 相关的片段:
<build>
<plugins>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<maxMemory>1024m</maxMemory>
<proguardInclude>${basedir}/proguard.conf</proguardInclude>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
<exclusions>
<exclusion>
<groupId>com.company.package</groupId>
</exclusion>
</exclusions>
</configuration>
</plugin>
</plugins>
</build>
不知何故,对于我们的情况,ff。 步骤消除了错误:
比较组件的pom.xml中的依赖项和proguard-maven-plugin标识的依赖项。 在我们的例子中,我们注意到proguard-maven-plugin识别出一些组件并不真正需要的依赖项。 实际上,甚至在组件的pom.xml中都没有指定这些依赖项。
执行步骤1后,修改组件的pom.xml,以便它排除Proguard已识别的不必要的依赖项(即使用排除参数)。 以下是一个示例代码段:
<build>
<plugins>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.10</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<maxMemory>1024m</maxMemory>
<proguardInclude>${basedir}/proguard.conf</proguardInclude>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
<lib>${java.home}/lib/jce.jar</lib>
</libs>
<!-- For some reason, these components are included by the plugin even if they are not dependencies of SES components so we need to explicitly indicate to proguard-maven-plugin to exclude them. -->
<exclusions>
<exclusion>
<groupId>p2.eclipse-plugin</groupId>
<artifactId>org.apache.geronimo.specs.geronimo-jms_1.1_spec</artifactId>
</exclusion>
<!-- other exclusions here -->
</exclusions>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.2</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
如果你有一个巨大的依赖列表,那么-libraryjars列表执行ProGaurd的结果命令行可能会变得太长。 在Windows上,错误消息可能看起来像CreateProcess error = 206,文件名或扩展名太长。
<putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>
在插件配置中,插件会将所有库jar复制到一个临时目录,并将该目录作为唯一的-libraryjars参数传递给ProGuard。 构建性能会稍差,但命令行会短得多。
有关proguard maven插件使用的详细信息,请参阅此处
原因是通常maven repo在用户的目录中,并且该路径为'classpath'上的每个jar添加,这使得它足够大以供Windows处理。
解决方案是您需要将maven repo移动到更短的路径 - 例如C:。 为此,您需要编辑maven settings.xml并添加标记,如下面的图像链接所示。 执行此操作后,您可以运行maven clean install。 这应该可以解决问题。
显然这个问题在较新版本的插件中得到了解决:
https://github.com/wvengen/proguard-maven-plugin/issues/113
使用这个新添加的配置选项,解决了我们的情况:
<configuration>
<generateTemporaryConfigurationFile>true</generateTemporaryConfigurationFile>
</configuration>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.