Issue
I am trying to obfuscate a jar-with-dependencies (although the same problem affects if I set as inFile the regular single jar).
I am using Java 8, but I have to use newer versions of Proguard and Proguard Maven Plugin, due to coverage of some jar dependencies that are from a higher version (otherwise I get an "Unsupported major-minor version" problem).
When executing "mvn clean install" the step is executed but I get a "proguard jar not found in pluginArtifacts error". See log below.
I have seen in Proguard Maven Plugin code that now you need (from 7.0.0) both proguard-base and proguard-core from com.guardsquare instead of the outdated previous version in net.sf.proguard - this one is not prepared for later jars.
Apparently the proguard jar is not found where I am specifying it - how should I include this dependency?
I am using this in my pom:
<build>
<plugins>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>proguard</goal></goals>
<configuration>
<injar>${project.build.finalName}-jar-with-dependencies.jar</injar>
<outjar>${project.build.finalName}-small.jar</outjar>
<proguardVersion>7.1.0</proguardVersion>
<options>
<option>-allowaccessmodification</option>
<option>-dontoptimize</option>
<option>-dontshrink</option>
<option>-dontnote</option>
<option>-dontwarn</option> <!-- added option to ignore com.sun missing classes -->
<option>-keepattributes Signature</option>
</options>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
<dependencies>
<dependency>
<groupId>com.guardsquare</groupId>
<artifactId>proguard-base</artifactId>
<version>7.1.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.guardsquare</groupId>
<artifactId>proguard-core</artifactId>
<version>7.1.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.4.0</version>
</plugin>
<plugins>
<pluginManagement>
</build>
Running it with -X debug flag:
[... proguard execution command which ends in:]
-printseeds, 'C:\workspace\xxx\target\proguard_seed.txt', -verbose, -allowaccessmodification, -dontoptimize, -dontshrink, -dontnote, -dontwarn, -keepattributes Signature]
...
[DEBUG] pluginArtifact: C:\User\myuser\.m2\repository\org\eclipse\sisu\org.eclipse.sisu.inject\0.0.0.M5\org.eclipse.sisu.inject-0.0.0.M5.jar
[DEBUG] pluginArtifact: C:\User\myuser\.m2\repository\org\codehaus\plexus\plexus-component-annotations\1.5.5\plexus-component-annotations-1.5.5.jar
[DEBUG] pluginArtifact: C:\User\myuser\.m2\repository\org\codehaus\plexus\plexus-classworlds\2.4\plexus-classworlds-2.4.jar
[INFO] proguard jar not found in pluginArtifacts
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 40.302 s
[INFO] Finished at: 2021-08-17T18:26:45
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.wvengen:proguard-maven-plugin:2.3.1:proguard (default) on project xxx: Obfuscation failed ProGuard (proguard.ProGuard) not found in classpath -> [Help 1]
The jar-with-dependencies is generated with Maven Assembly plugin. I am using Java 1.8.
Solution
I was actually using proguard.Proguard instead of proguard.ProGuard. Typo took a day out of me.
However, there is some extra trickyness associated, in case it helps anyone: proguard-maven-plugin
would not let me define newer versions of proguard dependencies except for the default one. E.g. 2.4.0
would only allow me to use 7.1.0-beta3
which is the default. It didn't recognize the libraries I would set in the dependencies
section inside the plugin (for example, for 7.1.1
).
Answered By - xmar
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)