Skip to content

Instantly share code, notes, and snippets.

@sdalichampt
Created April 13, 2016 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sdalichampt/afce3d91f3bbf208ae245271cfcab42c to your computer and use it in GitHub Desktop.
Save sdalichampt/afce3d91f3bbf208ae245271cfcab42c to your computer and use it in GitHub Desktop.
Numéro de port aléatoire pour un serveur tomcat embarqué lors de l'éxecution des tests d'intégration.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>pre-integration-test</phase>
<configuration>
<portNames>
<portName>tomcat.http.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<includes>
<include>**/*ITest.java</include>
</includes>
<systemPropertyVariables>
<tomcat.http.port>${tomcat.http.port}</tomcat.http.port>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
System.getProperty("tomcat.http.port")
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/myproject</path>
<port>${tomcat.http.port}</port>
</configuration>
<executions>
<execution>
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<fork>true</fork>
</configuration>
</execution>
<execution>
<id>stop-tomcat</id>
<phase>post-integration-test</phase>
<goals>
<goal>shutdown</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment