我想使用 Cargo 运行 Jetty,但我想将测试资源添加到 Jetty 类路径。
这是我的 Maven 配置:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.5</version>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals><goal>start</goal></goals>
<configuration>
<configuration>
<properties>
<cargo.jvmargs>${argLine}</cargo.jvmargs>
</properties>
</configuration>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals><goal>stop</goal></goals>
</execution>
</executions>
<configuration>
<container>
<containerId>jetty8x</containerId>
<type>embedded</type>
<log>${basedir}\target\cargo.log</log>
<output>${basedir}\target\jetty.log</output>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
</container>
<configuration>
<properties>
<cargo.servlet.port>8081</cargo.servlet.port>
<cargo.logging>high</cargo.logging>
<cargo.jvmargs>${argLine} -Denv=test</cargo.jvmargs>
</properties>
</configuration>
<deployables>
<deployable>
<pingURL>http://localhost:8081/myapp/</pingURL>
<pingTimeout>600000</pingTimeout>
<properties>
<context>myapp</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
在不使用 Cargo 的情况下,我在 Jetty 配置中使用useTestClasspath :
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.26</version>
<configuration>
<contextPath>myapp</contextPath>
<webAppSourceDirectory>WebContent</webAppSourceDirectory>
<stopPort>9699</stopPort>
<stopKey>foo</stopKey>
<scanIntervalSeconds>0</scanIntervalSeconds>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8081</port>
</connector>
</connectors>
<useTestClasspath>true</useTestClasspath>
<systemProperties>
<systemProperty>
<name>jettyMode</name>
<value>true</value>
</systemProperty>
</systemProperties>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
</dependencies>
</plugin>
有没有办法用一种useTestClasspath来配置 Cargo ?谢谢。