I want to
- build my maven modules top-down using snapshot dependencies among each other
- start my appserver with cargo
- run the integration-tests and
- keep the appserver running afterwards.

A simplified project structure might look like this

pom.xml
|_ moduleA
|_ moduleB
|_ moduleC
|_ appserver

Typically, one uses cargo plugin in the "appserver" project like this:

<plugin>
        <groupId>org.codehaus.cargo</groupId>
        <artifactId>cargo-maven2-plugin</artifactId>
        <executions>
                <execution>
                        <id>start-container</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                                <goal>start</goal>
                                <goal>deploy</goal>
                        </goals>
                </execution>
                <execution>
                        <id>stop-container</id>
                        <phase>post-integration-test</phase>
                        <goals>
                                <goal>stop</goal>
                        </goals>
                </execution>
        </executions>
        ...

Let's assume I changed "moduleB" and want to build "moduleB" and all its 
dependencies:

$ mvn clean install -pl moduleB -amd

This will create a reactor like this, taking down the appserver afterwards:

- moduleB
- moduleC
- appserver

In order to keep the appserver running, I would have to run the phase 
"integration-test" so that the phase "post-integration-test" will not be 
executed and the appserver keeps running.
But when I do this in the multi-project build, "install" will not be executed 
on moduleA and moduleB, causing the local repository not to be updated, which 
in turn will not start the appserver with the most up-to-date snapshots, right?

I assume I need to move the cargo plugin to a custom profile 
"run-appserver-and-shutdown" and duplicating the plugin to a 2nd one named 
"run-appserver-and-keep-running", invoke one or the other depending on what I 
want:

$ mvn clean install -pl moduleB -amd -Prun-appserver-and-shutdown
$ mvn clean install -pl moduleB -amd -Prun-appserver-and-keep-running

Is there any simpler and cleaner solution?

Thanks a lot,
Jonas






Reply via email to