Proguard Maven Plugin Ignores Injar Jar Name

I am using the Maven Assembly Plugin to extract my project into a jar file. And as a result, the extracted jar file is getting “jar-with-dependencies” appended to its name.

However, this should not be a problem for the proguard plugin since I can specify the name of the jar in its injar element like this: <injar>${project.build.finalName}-jar-with-dependencies.jar</injar>

But for some reason, as it can be seen on the error message, it is never able to locate the jar because it is looking for its original name, not the one with “-jar-with-dependencies” when I compile it with this command: mvn clean compile assembly:single proguard:proguard

Error Message

[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:UsersDeveloperKurtJavaProjectsMyProjecttargetMyProject.jar ->

Once this didn’t work out, I changed the jar file’s name in the target directory to “MyProject.jar” and executed the proguard plugin without cleaning, it was able to find the 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>

Answer

It turns out that the execution element should be closed before the configuration element

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