我在做同样的事情,John,但我对 Jetty 插件采取了不同的方法。我认为最终的结果是一样的。我正在开发一个集成测试套件来针对多个 Web 服务 WAR 运行。我dependency:copy
在package
阶段中使用,然后是为<contextHandler/>
s 配置的列表maven-jetty-plugin
:
<project>
…
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-wars</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/wars-to-be-tested</outputDirectory>
<stripVersion>true</stripVersion>
<artifactItems>
…
<artifactItem>
<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>version</version>
<type>war</type>
</artifactItem>
…
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.1.3.v20100526</version>
<configuration>
…
<contextHandlers>
…
<contextHandler implementation="org.mortbay.jetty.plugin.JettyWebAppContext">
<war>${project.build.directory}/wars-to-be-tested/artifactId.war</war>
<contextPath>/context</contextPath>
</contextHandler>
</contextHandlers>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>stop</goal>
<goal>run</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>
</executions>
</plugin>
</plugins>
</build>
</project>
我更愿意将各种战争声明为依赖项,然后用于dependency:copy-dependencies
设置wars-to-be-tested
目录;这将允许 Maven 反应器确定它需要在将要测试的战争之后构建我的集成测试模块。我遇到的问题是 Jetty 插件认为我想“覆盖”所有被列为依赖项的战争(在我看到它发生之前我什至从未听说过这个概念);我不知道允许这种情况发生是否会伤害任何东西,但我不喜欢它,所以我采用了这种dependency:copy
方法。
这只是使用 Cargo 的替代方法。我会自己研究,但我只是想提供另一种方法。