Friday, 21 October 2011

Apache Tomcat Maven Plugin Features

Recently I posted some informations regarding the move from codehaus to ASF of the Tomcat Maven plugin and about the support of tomcat7 in trunk code.

So now in this post, I'd like to talk of the features I prefer.

Run goal in multi modules with Maven3

Usually with Apache Maven, your application code is splitted in some modules to respect the Separation Of Concern paradigm.
Something like :


So to test your webapp module you have to install all other modules first which is time/io consuming.
Now with Apache Maven 3 and the Tomcat Maven Plugin (from Codehaus version 1.1 or now the 2.0-SNAPSHOT from Apache), you can simple use the goal run from the root directory and the plugin will see various modules build output and include those automatically in the embeded tomcat in the webapp class loader.

Build a standalone executable war/jar

You can now build a standalone jar which will contains Apache Tomcat needed classes and your wars.
See documentation.
This will produce a similar jar as for the Jenkins distribution.
At the end you will be able to run the produced jar with a simple:

java -jar yourjar

And that's will start Apache Tomcat without need of any installations !

NOTE: it's very recent feature based on my need :-)
So all issues/feedback or some RFE are really welcome!

Have Fun!

Apache Maven, Maven, Apache Tomcat, Tomcat, Apache are trademarks of The Apache Software Foundation.


Tim Pizey said...

Both very welcome features, and necessary if Tomcat plugin is to catch up with Jetty plugin ;)

nicolas said...


It would be a dream to have a example into github with these 3 maven module for one project. I am trying to do that as a big newbie

Thanks a lot.
Best regards

olamy said...

See the archetype which generate such project sample here