Proprocured Maven 插件忽略 Injar Jar 名称

Proguard Maven Plugin Ignores Injar Jar Name

我正在使用 Maven 程序集插件将我的项目提取到一个 jar 文件中。结果,提取的 jar 文件在其名称后附加了“jar-with-dependencies”。

但是,这对于混淆器插件来说应该不是问题,因为我可以在其 injar 元素中指定 jar 的名称,如下所示:<injar>${project.build.finalName}-jar-with-dependencies.jar</injar>

但由于某种原因,正如在错误消息中所见,它永远无法找到 jar,因为它正在寻找其原始名称,而不是带有“-jar-with-dependencies”的名称我用这个命令编译它:mvn clean compile assembly:single proguard:proguard

错误信息

[ERROR] Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.0.8:proguard (default-cli) on project MyProject: Can't find file C:\Users\DeveloperKurt\JavaProjects\MyProject\target\MyProject.jar ->

一旦这没有解决,我将目标目录中的 jar 文件的名称更改为“MyProject.jar”并在没有清理的情况下执行 proguard 插件,它能够找到 jar。

pom.xml

<dependencies>
        <!-- https://mvnrepository.com/artifact/com.github.wvengen/proguard-maven-plugin -->
        <dependency>
            <groupId>com.github.wvengen</groupId>
            <artifactId>proguard-maven-plugin</artifactId>
            <version>2.0.13</version>
        </dependency>

        <dependency>
            <groupId>net.sf.proguard</groupId>
            <artifactId>proguard-base</artifactId>
            <version>5.2</version>
            <scope>runtime</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <mainClass>com.myproject.Launcher</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.github.wvengen</groupId>
                <artifactId>proguard-maven-plugin</artifactId>
                <version>2.0.8</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>proguard</goal>
                        </goals>
                        <configuration>
                            <injar>${project.build.finalName}-jar-with-dependencies.jar</injar>
                            <proguardVersion>5.2</proguardVersion>
                            <options>
                                <option>-allowaccessmodification</option>
                                <option>-dontoptimize</option>
                                <option>-dontshrink</option>
                                <option>-dontnote</option>
                                <option>-dontwarn</option> 
                                <option>-keepattributes Signature</option>
                            
                            </options>
                            <libs>
                                <lib>${java.home}/lib/rt.jar</lib>
                            </libs>

                        </configuration>
                    </execution>
                </executions>
            </plugin>

原来执行元素应该在配置元素之前关闭

<configuration>
<plugin>
    <groupId>com.github.wvengen</groupId>
    <artifactId>proguard-maven-plugin</artifactId>
    <version>2.0.8</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>proguard</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <injar>${project.build.finalName}-jar-with-dependencies.jar</injar>
        <proguardVersion>5.2</proguardVersion>
        <options>
            <option>-allowaccessmodification</option>
            <option>-dontoptimize</option>
            <option>-dontshrink</option>
            <option>-dontnote</option>
            <option>-dontwarn</option>
            <option>-keepattributes Signature</option>
        </options>
        <libs>
            <lib>${java.home}/lib/rt.jar</lib>
        </libs>
    </configuration>
</plugin>