maven-2soapuipom.xmlmaven-assembly-pluginmaven-jetty-plugin

How to make jetty-maven-plugin deploy a war that is retrieved from a repository?


I'm setting up an integration test module for a good sized web project. The integration test module is separated from the web project itself, and it has it's own pom.

The idea is to use the maven-soapui-plugin to send requests and verify the response. Setting up the soapui-plugin is no hassle. However, I'm having trouble with figuring out how I can tell the jetty-maven-plugin to deploy a war from a remote repository.

If I have understood correctly, the jetty-maven-plugin has a property called '<webApp>/<webApp>' which lets me specify the war file to deploy. The problem is that the war file is not present in the module itself.

I have heard that I can use the maven assembly plugin to retrieve the war from a repository via the projects artifactId, but I am yet to figure out how I would go about doing so.

Here's a summary of what I want:

  1. Retrieve a specific war from a repository or the like, in example via its artifactId.
  2. Deploy this war to the jetty-maven-plugin (goal deploy-war?)
  3. get maven-soapui-plugin to run tests and report the results back in the integration-test phase.

I am pretty sure I've got step 3 covered, but I am very unsure how to achieve step 1 and 2.

Any help is greatly appreciated


Solution

  • It is maybe possible to use dependency:copy to retrieve the war, unpack it and to get the whole thing working with the maven jetty plugin, but this would be hacky and kinda ugly. A cleaner solution would be to use the Maven Cargo plugin and this is my suggestion. Below, a sample POM showing how to retrieve a WAR artifact using its coordinates and how to deploy it on an embedded Jetty container using Cargo:

    <dependencies>
      <dependency>
        <groupId>war group id</groupId>
        <artifactId>war artifact id</artifactId>
        <type>war</type>
        <version>war version</version>
      </dependency>
      ...
    </dependencies>
    ...
    <build>
      <plugins>
        <plugin>
          <groupId>org.codehaus.cargo</groupId>
          <artifactId>cargo-maven2-plugin</artifactId>
          <configuration>
            <!-- Container configuration -->
            <container>
              <containerId>jetty6x</containerId>
              <type>embedded</type>
            </container>
            <!-- Configuration to use with the container or the deployer -->
            <configuration>
              <deployables>
                <deployable>
                  <groupId>war group id</groupId>
                  <artifactId>war artifact id</artifactId>
                  <type>war</type>
                  <properties>
                    <context>war context</context>
                  </properties>
                </deployable>
              </deployables>
            </configuration>
            <!-- Don't wait, execute the tests after the container is started -->
            <wait>false</wait>
          </configuration>
          <executions>
            <execution>
              <id>start-container</id>
              <phase>pre-integration-test</phase>
              <goals>
                <goal>start</goal>
              </goals>
            </execution>
            <execution>
              <id>stop-container</id>
              <phase>post-integration-test</phase>
              <goals>
                <goal>stop</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        ...
      </plugins>
      ...
    </build>
    

    Finally, just bind the soapui plugin on the integration-test phase.