Class JettyRunMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="run", requiresDependencyResolution=TEST) @Execute(phase=TEST_COMPILE) public class JettyRunMojo extends AbstractUnassembledWebAppMojo
This goal is used in-situ on a Maven project without first requiring that the project is assembled into a war, saving time during the development cycle.

The plugin runs a parallel lifecycle to ensure that the "test-compile" phase has been completed before invoking Jetty. This means that you do not need to explicity execute a "mvn compile" first. It also means that a "mvn clean jetty:run" will ensure that a full fresh compile is done before invoking Jetty.

Once invoked, the plugin can be configured to run continuously, scanning for changes in the project and automatically performing a hot redeploy when necessary. This allows the developer to concentrate on coding changes to the project using their IDE of choice and have those changes immediately and transparently reflected in the running web container, eliminating development time that is wasted on rebuilding, reassembling and redeploying. Alternatively, you can configure the plugin to wait for an <enter> at the command line to manually control redeployment.

You can configure this goal to run your unassembled webapp either in-process with maven, or forked into a new process, or deployed into a jetty distribution.

  • Field Details

    • scan

      @Parameter(defaultValue="-1", property="jetty.scan", required=true) protected int scan
      Controls redeployment of the webapp.
      1. -1 : means no redeployment will be done
      2. 0 : means redeployment only occurs if you hit the ENTER key
      3. otherwise, the interval in seconds to pause before checking and redeploying if necessary
    • scanner

      protected Scanner scanner
      Scanner to check for files changes to cause redeploy
    • embedder

      protected JettyEmbedder embedder
      Only one of the following will be used, depending the mode the mojo is started in: EMBED, FORK, EXTERNAL
    • forker

      protected JettyForker forker
    • homeForker

      protected JettyHomeForker homeForker
  • Constructor Details

    • JettyRunMojo

      public JettyRunMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Overrides:
      execute in class AbstractWebAppMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • startJettyEmbedded

      public void startJettyEmbedded() throws org.apache.maven.plugin.MojoExecutionException
      Specified by:
      startJettyEmbedded in class AbstractWebAppMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • startJettyForked

      public void startJettyForked() throws org.apache.maven.plugin.MojoExecutionException
      Specified by:
      startJettyForked in class AbstractWebAppMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • startJettyHome

      public void startJettyHome() throws org.apache.maven.plugin.MojoExecutionException
      Specified by:
      startJettyHome in class AbstractWebAppMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • configureScanner

      protected void configureScanner() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • gatherScannables

      public void gatherScannables() throws Exception
      Throws:
      Exception
    • restartWebApp

      public void restartWebApp(boolean reconfigure) throws Exception
      Stop an executing webapp and restart it after optionally reconfiguring it.
      Parameters:
      reconfigure - if true, the scanner will be reconfigured after changes to the pom. If false, only the webapp will be reconfigured.
      Throws:
      Exception