I’m a little puzzled by proguard.
I have this setting in my pom.xml
Firstly, < injar > tag doesn’t work…final call of proguard doesn’t contain -injars if I use this tag.
Secondly, I’m not sure if it’s possible to obfuscate only one jar that takes place in WEB-INF/lib(I compile all my code in the one jar) and filter every other libs.
<plugin>
<groupId>com.pyx4me</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>proguard</goal>
</goals>
</execution>
</executions>
<configuration>
<proguardVersion>4.8</proguardVersion>
<obfuscate>true</obfuscate>
<maxMemory>1024m</maxMemory>
<includeDependency>false</includeDependency>
<options>
<option>-injars target/Test.war</option>
<option>-ignorewarnings</option>
</options>
<outjar>target/Test-obf.war</outjar>
<attach>false</attach>
<outputDirectory>${project.build.directory}</outputDirectory>
<proguardInclude>${basedir}\proguard.conf</proguardInclude>
<libs>
<lib>${java.home}/lib/rt.jar</lib>
</libs>
<addMavenDescriptor>false</addMavenDescriptor>
<skip>false</skip>
</configuration>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard</artifactId>
<version>4.4</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
With that configuration I have a lot of warnings cause it seems that proguard tries to obfuscate every jar in WEB-INF/lib
Could someone spread the light on that. Thank you in advance.
Added:
The problem with output that stands in front of all parameters was very tricky for me. As I understood you should not use ${basedir} when you specify both injars and outjars in pom.xml. Cause ${basedir} turns to absolute path and intenaly proguard also put an absolute path.
First of all, I have never used ProGuard from Maven, only from Ant.
I compare your configuration file with one in here
In your case you configure
injarsandoutjarin different manner which is strange to see.In that case warnings come not from the fact that ProGuard tries to compile all the libs, but because when it obfuscates your filtered code it wants to see reference to extarnal libs. See this.
You would need to add for every external jar referenced in your code
This would probably help you to avoid many warning, but the real art start when you configure
-keepoptions.I would recommend to start with this configuration https://stackoverflow.com/a/7511926/1360074
If that works eventually try to get more obfuscation.