Project Summary
What is this?This project is a simple template for setting up Maven and Jetty. Why would you need that? Can't you just use the maven jetty plugin? Yes you can, but this template also is set up to make a zip containing all dependencies including Jetty and your webapplication.
What can you do with this? Unzip the package, and run the included start script and you have a complete webserver running with your application. This is actually all you need to run many of the webapplications you make, and is production tested.
Why?It eases deployments and upgrades and makes you less dependent of the work queue at your hosting provider. The only thing they need to make sure of is that you have a JVM available.
This is a setup similar to that we use at work. I was however trying to use the same thing for a pet project I have at home, but ended up spending too much time on little stupid details that I should have remembered. So I decided to create a template for the next time around.
This is how I like to do it. Your mileage may wary. If you think the standard template should include anything else or be changed just let me know and I'll see what I can do about it.
How to useTo get a feel with what this is you can: Download zip and unpackage Run mvn clean install Go into the myserver/target/appassembler directory. Run bin\myapp Go to http://localhost:8080/mywar and it displays a hello world page
What just happened? Maven packaged your war and server into a zip in myserver/target The appassembler directoy is almost what is inside the zip You could have unpacked the zip in the target directory and seen the same behaviour
You can start adding stuff immediatley, but you should probably first: Search for mygroup and replace appropriately Search for myapp and replace appropriately That should be it. :)
How does it do this?The template consists of one parent project and two subprojects. The projects are a war and a server project.
The war project is a standard maven war project except for one ting: it is a "thin war" where no dependencies are included in the WEB-INF/lib directory of the war. The dependencies get included and handled by the server project.
The server project uses the maven appassembler and assembly plugin to package a zip of the project. Inside this zip is the war, any dependencies needed in a standard maven repo structure and a script to start a Jetty server with your application.
Why not an archetype?I couldn't figure out how to do it. :) Suggestions are welcome. From what I could gather it would be hard to create a multimodule Archetype.
See alsoJetty reload from maven repo