2

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
  1. module-b has a dependency on module-a.
  2. module-a and module-b are both installed to my local maven repository.
  3. tester has dependencies on both module-a and module-b.
  4. My proguard.conf file is next to the parent-pom pom.xml file on the file system.
  5. 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.

Andrew Gray
  • 3,593
  • 3
  • 35
  • 62
  • This is still a blocker issue for me. Looking for an answer. Let me know if the question isn't clear. – Andrew Gray Jan 19 '15 at 10:11
  • No answers. no comments even? What more information would people like to get things going? Happy to provide more information, just not sure what else to add without input from others. – Andrew Gray Jan 27 '15 at 10:44

1 Answers1

3

I eventually got this working by:

  1. Using the Windows Proguard application and selecting relatively basic settings through the wizard
  2. Exporting the configuration
  3. Closing my eyes and pressing the go button.

..and it worked!

Andrew Gray
  • 3,593
  • 3
  • 35
  • 62