Search code examples
mavenosgiobfuscation

Using an obfuscator with OSGi declarative services


I'm trying to use ProGuard from Maven to obfuscate my OSGi program. I am also using the SCR plugin to handle declarative services.

Unfortunately, ProGuard obfuscates all names in the classes but does not readily understand the relationship with the serviceComponents.xml file.

I should be able to write a program that uses the ProGuard obfuscation dictionary to fix this myself, but I'm wondering if there's something already out there.

In other words:

  • If you are using OSGi declarative services, how do you obfuscate with ProGuard and Maven?
  • And otherwise, well, how do you obfuscate at all? I'm flexible in terms of obfuscators and build systems...

Thanks!


Solution

  • There is no ready-made solution that I'm aware of.

    I think the best approach is to manually or automatically parse your service component declarations to extract all relevant class and method names and use the ProGuard keepnames options on these classes and methods.