I have a plugin reference to proguard in a multi-module maven project.
The functionality of my project is fully tested and works...until I add proguard.
Structure of my Project
parent-pom
-module-a-pom
-module-b-pom
tester-pom
- module-b has a dependency on module-a.
- module-a and module-b are both installed to my local maven repository.
- tester has dependencies on both module-a and module-b.
- My proguard.conf file is next to the parent-pom pom.xml file on the file system.
- I configure proguard in both module-a and module-b pom.xml files.
My proguard config looks like so:
<plugin>
<groupId>com.github.wvengen</groupId>
<artifactId>proguard-maven-plugin</artifactId>
<version>2.0.8</version>
<executions>
<execution>
<id>process-classes-with-proguard</id>
<phase>process-classes</phase>
<goals>
<goal>proguard</goal>
</goals>
<configuration>
<injar>classes</injar>
<proguardVersion>5.1</proguardVersion>
<proguardInclude>${project.basedir}/../proguard.conf</proguardInclude>
<libs>
<lib>${java.bootstrap.classes}</lib>
<lib>${java.secure.socket.extension.classes}</lib>
<lib>${java.cryptographic.extension.classes}</lib>
</libs>
<obfuscate>true</obfuscate>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>net.sf.proguard</groupId>
<artifactId>proguard-base</artifactId>
<version>5.1</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</plugin>
I have the added complexity that my project is using GSON to deserialise some incoming JSON from an external component I have no control over.
Executing proguard as part of the build causes the GSON code to throw NullPointerExceptions
The code that is effected by proguard is:
Gson gson = new Gson();
Type collectionType = new TypeToken<ArrayList<MyType>>(){}.getType();
ArrayList<MyType> myTypes = gson.fromJson(json, collectionType);
If proguard is commented out in my pom files (so it doesn't execute), this code (and the rest of my project) works like a charm.
How can I configure proguard to obsfuscate my code but not break the functionality? Is this possible with a multimodule project?
Does anyone out there know how to configure proguard for a multimodule maven project?
NB: I have already tried this and it seemed to make no difference to the outcome.
I eventually got this working by:
..and it worked!