|
|
|||||||||||||||||||||||||||||||||||||||||||||
I lurk on a bunch of mailing lists via Gmane and recently came across this message in which Henri Yandell asks if it would be possible to write a tool using bytecode manipulation which strips out any dependency on commons-logging.
After getting in touch with Henri he suggested making it a generic tool that could strip out any dependency. That's pretty much right up my alley, and since I've had a few logging headaches of my own I figured it was worth a try. So I've checked in some experimental code to the Jar Jar Links project, which has similar dependency-reducing goals.
Here is an examples of stripping commons-logging out of commons-beanutils:
java -cp jarjar.jar com.tonicsystems.jarjar.DepKill \ commons-beanutils.jar org.apache.commons.logging > \ commons-beanutils-nologging.jar
First argument is the jar to process, remaining args are package names to kill.
The transformed jar is sent to stdout. The actual transformations performed are pretty simple. If J is the code in the jar that is being transformed, and K is a "killed package":
I haven't yet tried using this to strip out anything other than commons-logging, so feedback is welcome.