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:
- Build & obfuscate each module separately, combine them in the top module while dealing with keeping the interfaces.
- Assemble & obfuscate all my modules together, separate from the libraries.
- Build a huge fat file, and obfuscate it as a whole.
- 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'