If you read this post you surely know ShrinkWrap and Maven. The main issue is the boilerplate code needed to create a WebArchive in a Maven project. This is really easier since ShrinkWrap resolver has a correct implementation of the Maven resolver but it still looks useless. All projects end with a ShrinkWrapUtil utility class to do it.
On another side TomEE provides an utility module to ease ShrinkWrap usage called ziplock. It allows you, for instance, to find a File from a class (see JarLocation) or provides you some shortcuts to create Archives (see WebModule). These utilities were created because of TomEE tests need.
However since few days it includes something more general and interesting for any maven user: the Mvn class.
It comes in two flavors:
- static methods “war” and “testWar”: create a class using default maven configuration to create a war representing the current module (test war adds test scoped dependencies)
- a builder “Mvn.Builder” which allows you to customize the maven defaults.
In the first case just call “org.apache.ziplock.maven.Mvn.war()” or “org.apache.ziplock.maven.Mvn.testWar()” to get the archive (you can continue to customize it then).
In the second case you need to create a new “Mvn.Builder” then customize it and call “build”. For instance to customize the name of the WebArchive and the maven basedir:
new Mvn.Builder().name("myapp.war").basedir(new File("..")).build();
Moreover “org.apache.ziplock.maven.PreloadableWar” (and “org.apache.ziplock.maven.PreloadableTestWar”) is just a shortcut to be able to use “preloadClasses” feature of arquillian tomee adapters – see my previous post. Once configured just call “org.apache.ziplock.maven.PreloadableTestWar.war()” in your “@Deployment” method.