![](/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.