在执行proguard-maven-plugin时,“CreateProcess error=206,文件名或扩展名太长”。

时间:2022-02-26 14:33:09

We are developing our own Eclipse plugin jars used by our Eclipse-based application. We are currently using proguard-maven-plugin version 2.0.8 to obfuscate them. However, when running mvn install on some plugins, we are currently encountering the following error:

我们正在开发基于Eclipse的应用程序使用的Eclipse插件jar。我们目前正在使用proguard-maven-plugin版本2.0.8来混淆它们。但是,当在一些插件上运行mvn安装时,我们目前遇到以下错误:

[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]

Has anyone ever encountered this? If so, how did you solve the problem?

有人见过这个吗?如果是的话,你是如何解决这个问题的?

Note that I have actually seen this question and other related questions before deciding to ask but the answer by Brad Mace is not applicable to my case as the "CreateProcess error=206, The filename or extension is too long" is generated by Proguard and not by Javadoc. Initially, I think (correct me if I'm wrong) that either 1 of the 7 options given by espinchi or a variation of them might work but I'm not sure which one. Just to let you know my constraints in determining the solution:

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

  1. I'm not sure if all of the classpaths in this particular plugin are valid since this has been developed by someone else many, many years ago so I don't think I can still contact the developer. This makes me hesitant to reduce the classpaths for fear that it might actually do more harm than good.
  2. 我不确定这个插件中所有的类路径是否有效,因为这是别人在多年前开发出来的,所以我认为我还不能联系开发人员。这让我在减少类路径时犹豫不决,因为我担心这样做实际上弊大于利。
  3. I cannot use the switch to "use IntelliJ" option since this problem occurred on the Windows command line when doing mvn install and not in Eclipse IDE.
  4. 我不能使用“使用IntelliJ”选项,因为这个问题发生在Windows命令行上,而不是在Eclipse IDE中进行mvn安装。
  5. I think the other options are too tedious for me. I'm hoping there's a simpler solution.
  6. 我觉得其他的选择对我来说太乏味了。我希望有一个更简单的解决方案。

For reference, below is the Proguard-related snippet from my pom file:

以下是我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>

2 个解决方案

#1


0  

Somehow, for our case, the ff. steps eliminated the error:

不知何故,对于我们来说,ff。步骤消除错误:

  1. Compare the dependencies in the component's pom.xml and the dependencies identified by proguard-maven-plugin. In our case, we noticed that proguard-maven-plugin identified some dependencies that are not really need by the component. In fact, these dependencies are not even specified in the component's pom.xml.

    比较组件pom中的依赖项。xml和由proguard-maven-plugin标识的依赖项。在我们的例子中,我们注意到proguard-maven-plugin识别了一些组件实际上不需要的依赖项。事实上,这些依赖项甚至没有在组件的pom.xml中指定。

  2. After performing Step 1, modify the component's pom.xml such that it will exclude the unnecessary dependencies that Proguard has identified (i.e., use the exclusion parameter). Below is a sample snippet:

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

#2


0  

If you have a huge list of dependencies the list of -libraryjars the resulting command line to execute ProGaurd could become too long. On Windows the error message could look like CreateProcess error=206, The filename or extension is too long.

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

<putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>

in plugin configuration makes the plugin copy all the library jars to a single temporary directory and pass that directory as the only -libraryjars argument to ProGuard. Build performance will be a bit worse, but the command line will be much shorter.

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

for detailed information about proguard maven plugin usage please refer their here

有关proguard maven插件使用情况的详细信息请参考这里。

#1


0  

Somehow, for our case, the ff. steps eliminated the error:

不知何故,对于我们来说,ff。步骤消除错误:

  1. Compare the dependencies in the component's pom.xml and the dependencies identified by proguard-maven-plugin. In our case, we noticed that proguard-maven-plugin identified some dependencies that are not really need by the component. In fact, these dependencies are not even specified in the component's pom.xml.

    比较组件pom中的依赖项。xml和由proguard-maven-plugin标识的依赖项。在我们的例子中,我们注意到proguard-maven-plugin识别了一些组件实际上不需要的依赖项。事实上,这些依赖项甚至没有在组件的pom.xml中指定。

  2. After performing Step 1, modify the component's pom.xml such that it will exclude the unnecessary dependencies that Proguard has identified (i.e., use the exclusion parameter). Below is a sample snippet:

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

#2


0  

If you have a huge list of dependencies the list of -libraryjars the resulting command line to execute ProGaurd could become too long. On Windows the error message could look like CreateProcess error=206, The filename or extension is too long.

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

<putLibraryJarsInTempDir>true</putLibraryJarsInTempDir>

in plugin configuration makes the plugin copy all the library jars to a single temporary directory and pass that directory as the only -libraryjars argument to ProGuard. Build performance will be a bit worse, but the command line will be much shorter.

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

for detailed information about proguard maven plugin usage please refer their here

有关proguard maven插件使用情况的详细信息请参考这里。