1

I am in the process of transferring a java netbeans project that has proguard obfuscation, from ant to maven multi module. I am a newbie in maven, and after reading and trying many solutions & architectures for a few days now, I am still quite lost.

From what I have seen, there are to ways to structure my project:

option 1:                   option 2: 
module top                   module top
   module A                     module A
   module B                     module B
   module C                     module C
                                module assembly

The modules have inner dependencies between them. 'module top' is a module that has very little code, and it acts as a wrapper. In option 1, the pom.xml for packaging the project is in 'module top'. In option 2, 'module assembly' has no logic, just the pom.xml for packaging the project.

My goal is to package the project in one fat jar where the inner modules will be obfuscated using proguard plugin.

What I have tried so far:

I managed to obfuscate one module, but because the modules are dependent on each other, I need to keep the entire interface structure, otherwise the modules don't fit when wrapped together.

I have created a fat jar file of the entire project and used proguard to obfuscate it. Since it is a big file, around 20M, the process took a lot of time, around 15 minutes. The output file was small, about 4M, and it didn't work.

Right now I am trying to assemble all my code during the build to a distribution jar, and separate it from the library jars. my aim is to obfuscate only my modules, and add the libraries later (this is what I have seen is working for me in the ant project that I currently have).

So far all my attempts have not yielded a process that works. I can't attach the pom files because I am keep changing them when trying new stuff.

So to sum this up, these are the options as I see them:

  1. Build & obfuscate each module separately, combine them in the top module while dealing with keeping the interfaces.
  2. Assemble & obfuscate all my modules together, separate from the libraries.
  3. Build a huge fat file, and obfuscate it as a whole.
  4. Do the packaging inside 'module top' or using a dedicated 'module assembly'

What do you recommend? Any help would be appreciated

EDIT

I got a small breakthrough. using option2 and proguard GUI, I finally managed to create a working obfuscated jar. For first step I run maven-dependency-plugin with copy-dependencies to a lib folder.

Then in the proguard GUI I 'injar' all my modules, and 'libraryjar' all the rest, and created dist-obsfucated.jar

My current ModuleAssemble structure is like this:

project
    target
       dist-obsfucated.jar
       lib
         moduleA.jar 
         moduleB.jar 
         moduleC.jar 
         other_file1.jar
         other_file2.jar

How do I assemble all the jars to an executable jar? I need tell the assembly plugin to ignore the unobsfucated modules A through C in the lib folder

EDIT #2

I managed to solve it using 'maven-antrun-plugin'

justadev
  • 1,168
  • 1
  • 17
  • 32
  • First of all build your project without obfuscation and be sure everything works fine. Because maven is a completely different beast than ant. And multi-module maven project is another challenge you have to deal with. After all you should be very comfortable with maven to accomplish obfuscation for a multi-module project. I actually didn't recommend doing that before having enough experience with maven. I am not sure if helps but I found that link http://stackoverflow.com/questions/27665179/proguard-for-multiple-maven-module-project – cool Oct 05 '15 at 20:33
  • Thank you for your answer. The project without maven works. I managed even to generate a fat jar file. I have seen the link that you mentioned, but it doesn't really mention how he eventually solved the issue – justadev Oct 05 '15 at 20:47
  • Yeah I know. As I said there are completely different challenges to overcome here. maven, multi-module, obfuscation. So try one at a time otherwise it really can be a nightmare. I did that before like 6-7 years ago. We had a multi-module web project. We obfuscated each jar separately as far as I remember. But it took nearly one month to make it run and we were pretty comfortable with maven. Most of the time spent for proguard configurations. – cool Oct 05 '15 at 20:55

0 Answers0