Revert "Add start/stop goals to maven plugin"

This reverts commit 54e12a07e6.
This commit is contained in:
Phillip Webb
2015-04-16 12:32:06 -07:00
parent 2085a5b0cf
commit a8d099f6b8
25 changed files with 382 additions and 1918 deletions

View File

@@ -1,82 +0,0 @@
-----
Random port for integration tests
-----
Stephane Nicoll
-----
2015-04-16
-----
One nice feature of the Spring Boot test integration is that it can allocate a free
port for the web application. When the <<<start>>> goal of the plugin is used, the
Spring Boot application is started separately, making it difficult to pass the actual
port to the integration test itself.
The example below showcases how you could achieve the same feature using the
{{{http://mojo.codehaus.org/build-helper-maven-plugin/}build-helper-plugin}}:
---
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>reserve-tomcat-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>tomcat.http.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
<configuration>
<arguments>
<argument>--server.port=${tomcat.http.port}</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<test.server.port>${tomcat.http.port}</test.server.port>
</systemPropertyVariables>
</configuration>
</plugin>
...
</plugins>
...
</build>
---
You can now retrieve the <<<test.server.port>>> system property in any of your integration test
to create a proper <<<URL>>> to the server.

View File

@@ -19,10 +19,6 @@ Spring Boot Maven Plugin
* {{{./repackage-mojo.html}spring-boot:repackage}} repackages your jar/war to be executable.
* {{{./start-mojo.html}spring-boot:start}} and {{{./stop-mojo.html}spring-boot:stop}} to manage
the lifecycle of your Spring Boot application (i.e. for integration tests).
* Usage
General instructions on how to use the Spring Boot Plugin can be found on the {{{./usage.html}usage page}}. Some
@@ -46,8 +42,6 @@ Spring Boot Maven Plugin
* {{{./examples/run-debug.html}Debug the application}}
* {{{./examples/it-random-port.html}Random port for integration tests}}
[]

View File

@@ -9,19 +9,8 @@
Usage
The plugin provides several goals to work with a Spring Boot application:
* <<<repackage>>>: create a jar or war file that is auto-executable. It can replace the regular artifact or can be
attached to the build lifecyle with a separate <<classifier>>.
* <<<run>>>: run your Spring Boot application with several options to pass parameters to it.
* <<<start>>> and <<<stop>>>: integrate your Spring Boot application to the <<<integration-test>>> phase so that
the application starts before it.
[]
Each goal is further described below.
The plugin offers a goal for repackaging an application as an executable JAR/WAR as well as a goal
for running the application.
* Repackaging an application
@@ -151,49 +140,3 @@ mvn spring-boot:run
in such a way that any dependency that is excluded in the plugin's configuration gets excluded
from the classpath as well. See {{{./examples/exclude-dependency.html}Exclude a dependency}} for
more details.
* Working with integration tests
While you may start your Spring Boot application very easily from your test (or test suite) itself,
it may be desirable to handle that in the build itself. To make sure that the lifecycle of you Spring
Boot application is properly managed <around> your integration tests, you can use the <<<start>>> and
<<<stop>>> goals as desribed below:
---
<build>
...
<plugins>
...
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
...
</build>
---
Such setup can now use the {{{http://maven.apache.org/surefire/maven-failsafe-plugin/}failsafe-plugin}} to
run your integration tests as you would expect.
For more detailed examples of how to configure this goal see:
* {{{./examples/it-random-port.html}Random port for integration tests}}
[]

View File

@@ -10,7 +10,6 @@
<item name="Custom repackage classifier" href="examples/repackage-classifier.html"/>
<item name="Exclude a dependency" href="examples/exclude-dependency.html"/>
<item name="Debug the application" href="examples/run-debug.html"/>
<item name="Random port for integration tests" href="examples/it-random-port.html"/>
</menu>
<menu ref="reports"/>
</body>