The one maven plugin every maven web project should use

2011-02-25

While creating some new demonstration for Facelets, I am once again amazed by the ease of using the Jetty maven plugin. It makes it so unbelievable easy to quickly run your web app during development, update your code and "instantly" see the result. Just add these lines to your Web Application's pom.xml file (you probably want to configure the plugin further, but this basic setup will get you started)

<build>
<finalName>facelets.demo</finalName>
<plugins>
    <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>6.1.10</version>
        <configuration>
            <scanIntervalSeconds>10</scanIntervalSeconds>
            <scanTargets>
                <!-- as an example -->
                <scanTarget>${basedir}/src/main/webapp/WEB-INF/faces-config.xml</scanTarget>
            </scanTargets>
        </configuration>
    </plugin>

Now just run the following command mvn jetty:run (start having a happier face). Now change some JSPs, HTML you web.xml file, classes (compile them) and WHAM instant result (you can smile now).

Of course there is not much new here, IDEs and hot deployment do kind of the same thing-however the ease of using this approach is much easier (and often much much faster that relying on your IDE and Tomcat/JBoss etc).

There is much more to the relation between jetty and maven (integration testing for one). Check out the documentation for more information: http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin

This article does not necessarily reflect the technical opinion of EDC4IT, but purely of the writer. If you want to discuss about this content, please use thecontact ussection of the site