执行 proguard-maven-plugin 时,会发生"CreateProcess error=206, The filename or extension is too long"



我们正在开发自己的Eclipse插件jar,供基于Eclipse的应用程序使用。我们目前正在使用proguard-maven-plugin2.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)Javajdk1.7.0_55jrebinjava.exe": CreateProcess error=206, The filename or extension is too long -> [Help 1]

有人遇到过这种情况吗?如果是,你是如何解决问题的?

请注意,在决定提问之前,我实际上已经看到了这个问题和其他相关问题,但Brad Mace的回答不适用于我的情况,因为"CreateProcess error=206,文件名或扩展名太长"是由Proguard生成的,而不是由Javadoc生成的。起初,我认为(如果我错了,请纠正我)espinchi给出的7个选项中的一个或它们的变体可能有效,但我不确定是哪一个。只是想让你知道我在确定解决方案时的限制:

  1. 我不确定这个特定插件中的所有类路径是否都是有效,因为这是别人多年来开发的以前,所以我想我不能再联系开发人员了。这使得我犹豫是否要减少classpath,因为担心它可能真的会弊大于利
  2. 我无法使用开关来"使用IntelliJ"选项,因为在执行mvn安装时,Windows命令行上出现了此问题而不是在Eclipse IDE中
  3. 我认为其他选择对我来说太乏味了。我希望有一个更简单的解决方案

为了参考,下面是我的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>

如果您有一个庞大的依赖项列表-libraryjar列表,那么执行ProGaurd的命令行可能会过长。在Windows上,错误消息可能看起来像CreateProcess错误=206,文件名或扩展名太长。

<putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>

在插件配置中,插件将所有库jar复制到一个临时目录中,并将该目录作为唯一的-libraryjars参数传递给ProGuard。构建性能会差一点,但命令行会短得多。

有关proguard maven插件使用的详细信息,请参阅此处的

原因是maven repo通常在用户的目录中,并且该路径为"classpath"上的每个jar添加,这使得它足够大,可以让windows处理。

解决方案是,你需要将你的maven回购转移到一条更短的路径上——比如C:。要做到这一点,您需要编辑maven-settings.xml并添加一个标记,如下面的图像链接所示。完成此操作后,就可以运行maven clean install。这应该能解决问题。

Maven Issue

不知何故,对于我们的案例,ff.steps消除了错误:

  1. 比较组件pom.xml中的依赖项和proguard-maven插件标识的依赖项。在我们的案例中,我们注意到proguard-maven插件确定了一些组件并不真正需要的依赖项。事实上,这些依赖关系甚至没有在组件的pom.xml中指定

  2. 执行步骤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>

显然,这个问题在插件的新版本中得到了解决:

https://github.com/wvengen/proguard-maven-plugin/issues/113

使用这个新添加的配置选项,解决了我们的问题:

<configuration>
<generateTemporaryConfigurationFile>true</generateTemporaryConfigurationFile>
</configuration>

相关内容

最新更新