header

Torsten Curdt’s weblog

Maven2 minijar plugin

At ApacheCon I was bugging Jason and Brett to give me a little jumpstart with writing my first maven2 plugin. (Thanks, guys!) Now I’ve finally submitted the maven2 minijar plugin to the mojo jira at codehaus. Originally I’ve developed it to reduce the dependencies of jci to make the drools guys happy …but now it looks like it could be useful for other projects as well. It’s not as sophisticated as proguard that does even remove dead code inside classes. It just works on the class level. But comparing the results the difference is usually not thaaaat big. And beside proguard is GPL the configuration is not really suitable for using it through maven. With the minijar plugin all you need to call is “mvn minijar:minijar” and it will go through all the dependencies and create the minimal required (compile-time) jars for the built artifact to work.

Building jar: commons-jci/target/jakarta-commons-jci-1.0-SNAPSHOT.jar
[minijar:minijar]
commons-jci-1.0-SNAPSHOT-minimal.jar.jar classes:44 dependencies:130 => 100.0%
commons-collections-3.1-minimal.jar.jar classes:446 dependencies:518 => 2.0%
core-3.1.0-minimal.jar.jar classes:1255 dependencies:1469 => 31.0%
groovy-all-1.0-jsr-03-minimal.jar.jar classes:915 dependencies:1220 => 47.0%
janino-2.3.7-minimal.jar.jar classes:333 dependencies:414 => 64.0%
commons-logging-api-1.0.4-minimal.jar.jar classes:13 dependencies:57 => 45.0%
commons-io-1.1-minimal.jar.jar classes:41 dependencies:98 => 48.0%
commons-lang-2.1-minimal.jar.jar classes:110 dependencies:161 => 2.0%

The codebase even already includes some code to support dependency inlining. That’s next on the todo list for this little side project.


Update: it’s already available in the mojo sandbox in svn

    blog comments powered by Disqus