logo Jetty :: Jetty Maven Plugin

Jetty maven plugins

homepage: eclipse.org/jetty
fresh index:
last release: 3 months ago, first release: 9 years ago
packaging: maven-plugin
get this artifact from: central
see this artifact on: search.maven.org


Display vulnerabilities (snyk): Vulnerability check

This chart shows how much is this artifact used as a dependency in other Maven artifacts in Central repository and GitHub:


select version:

Add this snippet into pom.xml inside tag <project><build><plugins>:




Switch to artifact.
goals:
jetty:effective-web-xml

Generate the effective web.xml for a pre-built webapp. This goal will NOT first build the webapp, it must already exist.

jetty:help

Display help information on jetty-maven-plugin. Call mvn jetty:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

jetty:run

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.

jetty:run-war

This goal is used to assemble your webapp into a war and automatically deploy it to Jetty. Once invoked, the plugin runs continuously and can be configured to scan for changes in the project and to the war file and automatically perform a hot redeploy when necessary. You may also specify the location of a jetty.xml file whose contents will be applied before any plugin configuration. You can configure this goal to run your webapp either in-process with maven, or forked into a new process, or deployed into a jetty distribution.

jetty:start

This goal is similar to the jetty:run goal in that it it starts jetty on an unassembled webapp, EXCEPT that it is designed to be bound to an execution inside your pom. Thus, this goal does NOT run a parallel build cycle, so you must be careful to ensure that you bind it to a phase in which all necessary generated files and classes for the webapp have been created. This goal will NOT scan for changes in either the webapp project or any scanTargets or scanTargetPatterns. You can configure this goal to run your webapp either in-process with maven, or forked into a new process, or deployed into a jetty distribution.

jetty:start-war

This goal is used to run Jetty with any pre-assembled war. This goal does not have to be used with a project of packaging type "war". You can configure the "webApp" element with the location of either a war file or an unpacked war that you wish to deploy - in either case, the webapp must be fully compiled and assembled as this goal does not do anything other than start jetty with the given webapp. If you do not configure the "webApp" element, then the goal will default to using the war of the webapp project. This goal is designed to be bound to a build phase, and NOT to be run at the command line. It will not block waiting for jetty to execute, but rather continue execution. This goal is useful e.g. for launching a web app in Jetty as a target for unit-tested HTTP client components via binding to the test-integration build phase. You can configure this goal to run the webapp either in-process with maven, or forked into a new process, or deployed into a {@code ${jetty.base}} directory.

jetty:stop

This goal stops a running instance of jetty. The stopPort and stopKey parameters can be used to configure which jetty to stop.

Often used code snippets:

<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>${jetty.plugin.version}</version>
  <configuration>
    <scanIntervalSeconds>2</scanIntervalSeconds>
  </configuration>
</plugin>
<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.2.11.v20150529</version>
  <configuration>
    <scanIntervalSeconds>10</scanIntervalSeconds>
    <webApp>
      <contextPath>/</contextPath>
    </webApp>
  </configuration>
</plugin>
<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>9.2.10.v20150310</version>
  <configuration>
    <webAppSourceDirectory>${project.build.directory}/site/allure-maven-plugin</webAppSourceDirectory>
    <stopKey>stop</stopKey>
    <stopPort>1234</stopPort>
  </configuration>
</plugin>
<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>${jetty.version}</version>
  <configuration>
    <contextPath>/</contextPath>
    <webApp>
      <contextPath>/</contextPath>
      <webInfIncludeJarPattern>.*/.*jersey-[^/]\.jar$</webInfIncludeJarPattern>
    </webApp>
    <war>${project.build.directory}/${project.build.finalName}.war</war>
  </configuration>
</plugin>
<plugin>
  <groupId>org.eclipse.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <version>${jetty9.version}</version>
  <configuration>
    <systemProperties>
      <systemProperty>
        <name>maven.project.build.directory.test-classes</name>
        <value>${project.build.directory}/test-classes</value>
      </systemProperty>
    </systemProperties>
    <jettyXml>${project.basedir}/src/test/jetty/jetty.xml,${project.basedir}/src/test/jetty/jetty-ssl.xml,${project.basedir}/src/test/jetty/jetty-http.xml,${project.basedir}/src/test/jetty/jetty-https.xml</jettyXml>
  </configuration>
</plugin>

© Jiri Pinkas 2015 - 2022. All rights reserved! Admin login To submit bugs / feature requests please use this github page
related: JavaVids | Top Java Blogs | Java školení
Apache and Apache Maven are trademarks of the Apache Software Foundation. The Central Repository is a service mark of Sonatype, Inc.