My linux world » jetty-maven-plugin

jetty-maven-plugin


Jetty maven plugin allows you to deploy your webapp in jetty.
Here is an example that shows how to deploy your webapp in jetty and launch integration tests.

Add jetty maven plugin

We ask maven to fire the goal ‘deploy-war’ at the phase ‘pre-integration-test’ to deploy the webapp in jetty.
This will have the benefit to be able to launch integration tests at the phase ‘integration_test’.
Then we will fire the goal ‘stop’ at the phase ‘post-integration-test’ to stop the container.

<plugins>
(...)
 
  <plugin>
	<groupId>org.eclipse.jetty</groupId>
	<artifactId>jetty-maven-plugin</artifactId>
	<version>${jetty-maven.version}</version>
 
	<configuration>
		<webApp>
			<contextPath>/</contextPath>
		</webApp>
		<httpConnector>
			<port>8080</port>
		</httpConnector>
		<scanIntervalSeconds>10</scanIntervalSeconds>
		<stopPort>9005</stopPort>
		<stopKey>STOP</stopKey>
	</configuration>
 
	<executions>
 
		<execution>
			<id>start-jetty</id>
			<phase>pre-integration-test</phase>
			<goals>
				<goal>deploy-war</goal>
			</goals>							
		</execution>
		<execution>
			<id>stop-jetty</id>
			<phase>post-integration-test</phase>
			<goals>
				<goal>stop</goal>
			</goals>
		</execution>
 
	</executions>
    </plugin>
 
(...)
</plugins>

Launch integration tests

When the container is started, we launch maven-failsafe-plugin goal ‘integration-test’ at phase ‘integration-test’.

<plugins>
(...)
 
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>${maven-failsafe.version}</version>
    <executions>
      <execution>
	<id>integration-test</id>
	<goals>
	  <goal>integration-test</goal>
	</goals>
     </execution>
     <execution>
       <id>verify</id>
         <goals>
	   <goal>verify</goal>
	 </goals>
     </execution>
   </executions>
   <configuration>
     <encoding>UTF-8</encoding>
   </configuration>
 </plugin>
 
(...)
</plugins>

Read More


Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.