Jetty has a sexy new plugin for Ant that has the same features as the Maven plugin. So if you didn’t want to move from Ant to Maven, but you still want fast webapp development, now you can have it!

The Jetty Maven plugin greatly shortens your development cycle by allowing you to run jetty on your Maven webapp project without first having to assemble it into a fully-formed webapp. Moreover, it’s able to scan the webapp and automatically redeploy it when changes are detected (eg to class files, descriptors, jars etc). You can imagine how convenient that is when you’re using an IDE – you modify the source, the IDE compiles it in the background and your changes are then immediately reflected in the executing container.

Not everyone, however, is in a position to change to using Maven for building their webapps. Many folks are happy with (or are stuck with) using Ant, but would love to have the advantages of the Maven plugin.

Well, now they can! The Jetty Ant plugin brings you those same rapid development features.

Like the Maven plugin, the Ant plugin also directly supports configuration of jetty components like connectors, realms, request logs etc. Similarly, it also supports the use of a jetty.xml file to give you total control of the container environment for your webapp. As you’d expect, you can also specify a jetty-env.xml for doing fine-grained configuration of the JNDI resources.

Once you’ve done your initial configuration and setup it’s as easy as typing:


Big thanks to Jakub Pawlowicz and Sabre Holdings for this outstanding contribution to the Jetty project!

Jetty Ant Plugin

15 thoughts on “Jetty Ant Plugin

  • March 9, 2007 at 3:46 am

    Not that I want to get into some kind of pissing contest here, but I just wanted to mention that the maven plugins don’t have quite the same feature set. 

    For example, AFAIK, the jetty plugin is the only one which scans for changes and automatically redeploys.

    However, I’m sure if that feature isn’t implemented yet, the Tomcat guys will be trying to catch up to us soon 🙂

  • March 18, 2007 at 3:27 am

    I’ve been unable to locate the jetty-ant JAR in *any* maven2 repository, as of 3/14/2007. Any suggestions?

  • March 18, 2007 at 9:16 pm

    The plugin is an optional extra and is currently not automatically built and pushed to the maven repos. For the moment, you have to download the jetty bundle from and build it yourself – very simple (I also like the irony that it is built with maven 🙂 )

    We’ll take a look to see if there’s a way we can push pre-built jars from the jetty/extras module to a repo.


  • March 23, 2007 at 7:10 pm

    I would like to start up Jetty programmatically but with all of the features of the Maven plugin (e.g.. monitor directories). Is there a means to do this already?

    I have just been down the road of creating the Jetty6RunWarExploded manually, but reached a deadend when this class because the webApp property is set using a @property attribute, and no javabean property is present.

    Maybe I should look at the Ant task source? It would be cool if a launcher class that monitored directories (and allowed for multiple resource base directories) was part of Jetty proper and the maven and ant tasks could just delegate to that module. It would also allow someone who wants to programmatically start Jetty to have their cake also.

  • March 23, 2007 at 7:29 pm

    Jetty Ant Plugin  Thank You


    Best Regards…

  • March 23, 2007 at 11:33 pm

    I think we have what you want 🙂  Take a look at the wiki entry at  The context deployer will do pretty much what the maven and ant plugins do in terms of deploying your webapp, watching for changes to it and automatically redeploying it when necessary.


  • May 8, 2007 at 10:00 am

    I’d like to start jetty with additional vm parameters.
    Is it possible to put such parameters to the Jetty Ant Plugin?

    Best regards Andreas

  • May 9, 2007 at 7:34 am

    Hi Andreas,

    I believe there are at least two ways to do that:

    1. Provide your VM args via ANT_OPTS environment property – your args will be available to the whole ant process;
    2. Execute your Jetty task in a separate ant process. You can do it via ‘exec’ task in ant. It allows you to specify VM args directly from the ant script.
      Please note, that it doesn’t work well on Windows OS, because of some nasty bug (subprocess won’t close if you close the parent process).

    As you can see there’s no way to specify VM args in the jetty task itself, which is because the ant plugin is not executed in a separate process.
    However, we use both approaches to enable Java debugging for our web application and it works perfectly well.

    I hope that answers your question.

    Best Regards,
    Jakub Pawlowicz

  • May 14, 2007 at 3:31 pm

    Hi Jacub,

    thanks for the suggestions. I think, in using the plugin for debugging and testing this is a quite good solution.

    Best Regards,

  • March 5, 2010 at 4:47 am

    Newbie question:
    How can http_requests be handled in Ant when running Jetty?

  • April 12, 2010 at 11:58 am

    I am looking for (a set of) ant tasks enabling the mapping of http incoming request parameters onto ant properties. I realize this is currently not the scope of the Jetty plug-in.
    I found a Listener task in Anteater which does that but with Tomcat.
    Another similar though limited attempt is Antserver in Antcontrib.

  • April 13, 2010 at 7:48 am


    Interesting! I haven’t heard of such a set of ant tasks before. If you come across anyone willing to contribute an impl for Jetty, please email and let us know.



  • June 22, 2011 at 3:25 am

    I am struggling with setting UserRealm from ant script. Do you have an example?

Comments are closed.