Is that possible to customize a maven build lifecycle without writing a plugin? I want to customize my project to package it without running tests, then run the tests. The background is that the tests are running on HTTPUnit and it needs a fully constructed web application directory structure.
3 Answers
As suggested by khmarbaise you can use maven-failsafe-plugin which is an extension of maven-surefire-plugin.
Maven lifecycle has four phases perfect for your intent:
pre-integration-test
for setting up the integration test environment.integration-test
for running the integration tests.post-integration-test
for tearing down the integration test environment.verify
for checking the results of the integration tests.
generally speaking during the pre-integration-test
we start the server
eg:
<executions>
[...]
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run-exploded</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
I use this plugin with Hudson; in Maven Build Customization - Chapter 5 you can find further details.

- 7,469
- 2
- 48
- 70
It seems that you are writing integration tests.
You could use maven-failsafe-plugin. This plugin is executed by default at the integration-test phase of the maven build lifecycle (which is after the packaging phase)...

- 28,720
- 11
- 94
- 117
For those purposes you need the integration-test phase which exactly is intended for such things. It's after the packaging phase but before install/deploy phase. This can be achieved by using the maven-failsafe-plugin. You can find a full example here.

- 92,914
- 28
- 189
- 235