Run Proguard on multi-module project as "one piece"

Viewed 3620

TLDR: How to pass proguard mapping to javac to compile against obfuscated library ?

That's long, but I don't see how to make it shorter:

Background: I have the following product setup:

Android Studio project - Library module - (sub)module Core - (sub)module A - (sub)module B - (sub)module C - Sample App module - ... Other modules

Each of library submodules A, B, C reference classes in Core, but A, B, C independent among themselves. Conceptually similar to Play Services where user can only have code and required sub-module. Each of the library submodules has external APIs but also many internal classes The goal is to be able to distribute Core, A, B, C as independent aar-s.

Goal: obfuscate all sub-modules together leaving only public APIs exposed but package and distribute them separately in obfuscated/optimized form.

Issue: I do not see how to use it with straightforward gradle configuration. Custom build system is needed here, Unless there is a any known solution?

What is needed here is:

  • Java-Compile all sub-modules together
  • Proguard-obfuscate them together
  • Run all the rest of the build process separately

Where is normal build process is for each module is: - Compile -> do everything incl. obfuscation -> package

Straight forward setup fails at the compilation of the first submodule after Core. If it only would be possible to pass Proguard mapping.txt as an input to Java compiler... But I could not find such an option. Any ideas?

Thanks!!!

2 Answers
Related