jetty:run

Full name:

org.mortbay.jetty:maven-jetty-plugin:6.1.22:run

Description:

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 forks a parallel lifecycle to ensure that the "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.

You may also specify the location of a jetty.xml file whose contents will be applied before any plugin configuration. This can be used, for example, to deploy a static webapp that is not part of your maven build.

There is a reference guide to the configuration parameters for this plugin, and more detailed information with examples in the Configuration Guide .

Attributes:

  • Requires a Maven 2.0 project to be executed.
  • Requires dependency resolution of artifacts in scope: runtime.
  • Invokes the execution of the lifecycle phase test-compile prior to executing itself.

Required Parameters

Name Type Since Description
classesDirectory File - The directory containing generated classes.
contextPath String - The context path for the webapp. Defaults to the name of the webapp's artifact.
scanIntervalSeconds int - The interval in seconds to scan the webapp for changes and restart the context if necessary. Ignored if reload is enabled. Disabled by default.
Default value is: 0.
testClassesDirectory File - The directory containing generated test classes.
tmpDirectory File - The temporary directory to use for the webapp. Defaults to target/jetty-tmp
webAppSourceDirectory File - Root directory for all html/jsp etc files

Optional Parameters

Name Type Since Description
connectors Connector[] - List of connectors to use. If none are configured then the default is a single SelectChannelConnector at port 8080. You can override this default port number by using the system property jetty.port on the command line, eg: mvn -Djetty.port=9999 jetty:run
contextHandlers ContextHandler[] - List of other contexts to set up. Optional.
daemon boolean -

Determines whether or not the server blocks when started. The default behavior (daemon = false) will cause the server to pause other processes while it continues to handle web requests. This is useful when starting the server with the intent to work with it interactively.

Often, it is desirable to let the server start and continue running subsequent processes in an automated build environment. This can be facilitated by setting daemon to true.


Default value is: false.
jettyConfig File - Location of a jetty xml configuration file whose contents will be applied before any plugin configuration. Optional.
jettyEnvXml File - The location of a jetty-env.xml file. Optional.
overrideWebXml File - A web.xml file to be applied AFTER the webapp's web.xml file. Useful for applying different build profiles, eg test, production etc. Optional.
reload String - reload can be set to either 'automatic' or 'manual' if 'manual' then the context can be reloaded by a linefeed in the console if 'automatic' then traditional reloading on changed files is enabled.
Default value is: automatic.
requestLog RequestLog - A RequestLog implementation to use for the webapp at runtime. Optional.
scanTargetPatterns ScanTargetPattern[] - List of directories with ant-style <include> and <exclude> patterns for extra targets to periodically scan for changes. Can be used instead of, or in conjunction with <scanTargets>.Optional.
scanTargets File[] - List of files or directories to additionally periodically scan for changes. Optional.
stopKey String - Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stop
stopPort int - Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stop
systemProperties SystemProperties - System properties to set before execution. Note that these properties will NOT override System properties that have been set on the command line or by the JVM. They WILL override System properties that have been set via systemPropertiesFile. Optional.
systemPropertiesFile File - File containing system properties to be set before execution Note that these properties will NOT override System properties that have been set on the command line, by the JVM, or directly in the POM via systemProperties. Optional.
useTestClasspath boolean - If true, the <testOutputDirectory> and the dependencies of <scope>test<scope> will be put first on the runtime classpath.
Default value is: false.
userRealms UserRealm[] - List of security realms to set up. Optional.
webAppConfig Jetty6PluginWebAppContext - The "virtual" webapp created by the plugin
webDefaultXml File - A webdefault.xml file to use instead of the default for the webapp. Optional.
webXml File - The location of the web.xml file. If not set then it is assumed it is in ${basedir}/src/main/webapp/WEB-INF

Parameter Details

classesDirectory :

The directory containing generated classes.
  • Type: java.io.File
  • Required: Yes
  • Expression: ${project.build.outputDirectory}

connectors :

List of connectors to use. If none are configured then the default is a single SelectChannelConnector at port 8080. You can override this default port number by using the system property jetty.port on the command line, eg: mvn -Djetty.port=9999 jetty:run
  • Type: org.mortbay.jetty.Connector[]
  • Required: No

contextHandlers :

List of other contexts to set up. Optional.
  • Type: org.mortbay.jetty.handler.ContextHandler[]
  • Required: No

contextPath :

The context path for the webapp. Defaults to the name of the webapp's artifact.
  • Type: java.lang.String
  • Required: Yes
  • Expression: /${project.artifactId}

daemon :

Determines whether or not the server blocks when started. The default behavior (daemon = false) will cause the server to pause other processes while it continues to handle web requests. This is useful when starting the server with the intent to work with it interactively.

Often, it is desirable to let the server start and continue running subsequent processes in an automated build environment. This can be facilitated by setting daemon to true.

  • Type: boolean
  • Required: No
  • Expression: ${jetty.daemon}
  • Default: false

jettyConfig :

Location of a jetty xml configuration file whose contents will be applied before any plugin configuration. Optional.
  • Type: java.io.File
  • Required: No

jettyEnvXml :

The location of a jetty-env.xml file. Optional.
  • Type: java.io.File
  • Required: No

overrideWebXml :

A web.xml file to be applied AFTER the webapp's web.xml file. Useful for applying different build profiles, eg test, production etc. Optional.
  • Type: java.io.File
  • Required: No

reload :

reload can be set to either 'automatic' or 'manual' if 'manual' then the context can be reloaded by a linefeed in the console if 'automatic' then traditional reloading on changed files is enabled.
  • Type: java.lang.String
  • Required: No
  • Expression: ${jetty.reload}
  • Default: automatic

requestLog :

A RequestLog implementation to use for the webapp at runtime. Optional.
  • Type: org.mortbay.jetty.RequestLog
  • Required: No

scanIntervalSeconds :

The interval in seconds to scan the webapp for changes and restart the context if necessary. Ignored if reload is enabled. Disabled by default.
  • Type: int
  • Required: Yes
  • Expression: ${jetty.scanIntervalSeconds}
  • Default: 0

scanTargetPatterns :

List of directories with ant-style <include> and <exclude> patterns for extra targets to periodically scan for changes. Can be used instead of, or in conjunction with <scanTargets>.Optional.
  • Type: org.mortbay.jetty.plugin.util.ScanTargetPattern[]
  • Required: No

scanTargets :

List of files or directories to additionally periodically scan for changes. Optional.
  • Type: java.io.File[]
  • Required: No

stopKey :

Key to provide when stopping jetty on executing java -DSTOP.KEY=<stopKey> -DSTOP.PORT=<stopPort> -jar start.jar --stop
  • Type: java.lang.String
  • Required: No

stopPort :

Port to listen to stop jetty on executing -DSTOP.PORT=<stopPort> -DSTOP.KEY=<stopKey> -jar start.jar --stop
  • Type: int
  • Required: No

systemProperties :

System properties to set before execution. Note that these properties will NOT override System properties that have been set on the command line or by the JVM. They WILL override System properties that have been set via systemPropertiesFile. Optional.
  • Type: org.mortbay.jetty.plugin.util.SystemProperties
  • Required: No

systemPropertiesFile :

File containing system properties to be set before execution Note that these properties will NOT override System properties that have been set on the command line, by the JVM, or directly in the POM via systemProperties. Optional.
  • Type: java.io.File
  • Required: No
  • Expression: ${jetty.systemPropertiesFile}

testClassesDirectory :

The directory containing generated test classes.
  • Type: java.io.File
  • Required: Yes
  • Expression: ${project.build.testOutputDirectory}

tmpDirectory :

The temporary directory to use for the webapp. Defaults to target/jetty-tmp
  • Type: java.io.File
  • Required: Yes
  • Expression: ${project.build.directory}/work

useTestClasspath :

If true, the <testOutputDirectory> and the dependencies of <scope>test<scope> will be put first on the runtime classpath.
  • Type: boolean
  • Required: No
  • Default: false

userRealms :

List of security realms to set up. Optional.
  • Type: org.mortbay.jetty.security.UserRealm[]
  • Required: No

webAppConfig :

The "virtual" webapp created by the plugin
  • Type: org.mortbay.jetty.plugin.Jetty6PluginWebAppContext
  • Required: No

webAppSourceDirectory :

Root directory for all html/jsp etc files
  • Type: java.io.File
  • Required: Yes
  • Expression: ${basedir}/src/main/webapp

webDefaultXml :

A webdefault.xml file to use instead of the default for the webapp. Optional.
  • Type: java.io.File
  • Required: No

webXml :

The location of the web.xml file. If not set then it is assumed it is in ${basedir}/src/main/webapp/WEB-INF
  • Type: java.io.File
  • Required: No
  • Expression: ${maven.war.webxml}