How to build obfuscated and osgified Java archives


(Robert Saenger) #1

Is there any way to create an obfuscated and osgified jar, i.e. back the OSGi processing on the obfuscted jar?

Or, how can I hook into the Jar Task processing before the OSGi processing starts, since the OSGi processing should rely on the obfuscated jar rather the original one?


(Peter Niederwieser) #2

The OSGi plugin operates on the contents of the ‘classes’ directory. Hence you should be able to write a task that obfuscates the contents of this directory and make the Jar task depend on that task. Or probably better, write the obfuscated code to a new directory and reconfigure the Jar task to package that directory. (One problem with overwriting the ‘classes’ directory is that ‘compileJava’ will never be up-to-date because obfuscation destroyed its output.)


(Robert Saenger) #3

I would like to follow this advice, but unfortunately the obfuscation library (yguard) only takes a jar as input.

Thus I would have to build a temporary JAR, obfuscate it, unzip its contents and pass it again to the Jar task. This seems a bit cumbersome. Isn’t there an easier way?

Does the OSGi plugin solely operate on

classes

?


(Peter Niederwieser) #4

Thus I would have to build a temporary JAR, obfuscate it, unzip its contents and pass it again to the Jar task. This seems a bit cumbersome. Isn’t there an easier way?

The OSGi plugin is somewhat limited. If you want to use it, I don’t see an easier way.