执行proguard-maven-plugin时,出现"CreateProcess error=206, The filename or extension is too long"
When executing proguard-maven-plugin, "CreateProcess error=206, The filename or extension is too long" occurs
我们正在开发我们自己的 Eclipse 插件 jar,供我们基于 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]
有人遇到过这种情况吗?如果有,您是如何解决问题的?
请注意,在决定提问之前,我实际上已经看到了 this question 和其他相关问题,但是 Brad Mace 的回答不适用于我的情况,因为 "CreateProcess error=206, The filename or extension is too long" 是由 Proguard 生成的,而不是由 Proguard 生成的Javadoc。最初,我认为(如果我错了请纠正我)espinchi 给出的 7 个选项中的任何一个或它们的变体都可能有效,但我不确定是哪一个。只是想让你知道我在确定解决方案时的局限性:
- 我不确定这个特定插件中的所有类路径是否都是
有效,因为这是由其他人开发多年的
之前,所以我认为我仍然无法联系开发人员。这使得
我犹豫要不要减少类路径,因为担心它实际上可能
弊大于利。
- 我无法使用切换到 "use IntelliJ" 选项,因为在执行 mvn install 时这个问题发生在 Windows 命令行上
而不是在 Eclipse IDE.
- 我认为其他选项对我来说太乏味了。我希望有一个更简单的解决方案。
作为参考,下面是我的 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 已识别的不必要的依赖项(即使用 exclusion 参数)。下面是一个示例片段:
<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>
如果您有大量的依赖项列表,那么执行 ProGaurd 的 -libraryjars 列表可能会变得太长。在 Windows 上,错误消息可能类似于 CreateProcess error=206,文件名或扩展名太长。
<putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>
在插件配置中使插件将所有库 jar 复制到一个临时目录,并将该目录作为唯一的 -libraryjars 参数传递给 ProGuard。构建性能会差一点,但命令行会短很多。
有关 proguard maven 插件使用的详细信息,请参阅他们的 here
原因是通常 maven 存储库位于用户目录中,并且该路径为“类路径”中的每个 jar 添加,这使得它足够大 windows 来处理。
解决方案是您需要将 Maven 存储库移动到更短的路径——比如 C:。为此,您需要编辑 Maven settings.xml 并添加一个标签,如下图 link 所示。执行此操作后,您可以 运行 maven clean install。这应该可以解决问题。
Maven Issue
我们正在开发我们自己的 Eclipse 插件 jar,供我们基于 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]
有人遇到过这种情况吗?如果有,您是如何解决问题的?
请注意,在决定提问之前,我实际上已经看到了 this question 和其他相关问题,但是 Brad Mace 的回答不适用于我的情况,因为 "CreateProcess error=206, The filename or extension is too long" 是由 Proguard 生成的,而不是由 Proguard 生成的Javadoc。最初,我认为(如果我错了请纠正我)espinchi 给出的 7 个选项中的任何一个或它们的变体都可能有效,但我不确定是哪一个。只是想让你知道我在确定解决方案时的局限性:
- 我不确定这个特定插件中的所有类路径是否都是 有效,因为这是由其他人开发多年的 之前,所以我认为我仍然无法联系开发人员。这使得 我犹豫要不要减少类路径,因为担心它实际上可能 弊大于利。
- 我无法使用切换到 "use IntelliJ" 选项,因为在执行 mvn install 时这个问题发生在 Windows 命令行上 而不是在 Eclipse IDE.
- 我认为其他选项对我来说太乏味了。我希望有一个更简单的解决方案。
作为参考,下面是我的 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 已识别的不必要的依赖项(即使用 exclusion 参数)。下面是一个示例片段:
<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>
如果您有大量的依赖项列表,那么执行 ProGaurd 的 -libraryjars 列表可能会变得太长。在 Windows 上,错误消息可能类似于 CreateProcess error=206,文件名或扩展名太长。
<putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>
在插件配置中使插件将所有库 jar 复制到一个临时目录,并将该目录作为唯一的 -libraryjars 参数传递给 ProGuard。构建性能会差一点,但命令行会短很多。
有关 proguard maven 插件使用的详细信息,请参阅他们的 here
原因是通常 maven 存储库位于用户目录中,并且该路径为“类路径”中的每个 jar 添加,这使得它足够大 windows 来处理。
解决方案是您需要将 Maven 存储库移动到更短的路径——比如 C:。为此,您需要编辑 Maven settings.xml 并添加一个标签,如下图 link 所示。执行此操作后,您可以 运行 maven clean install。这应该可以解决问题。
Maven Issue