[英]Add test classpath to Jetty run by Cargo
I would like to run Jetty by using Cargo but I would like to add test resources to Jetty classpath. 我想使用Cargo运行Jetty,但我想向Jetty classpath添加测试资源。
Here is my Maven configuration : 这是我的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>
Without using Cargo, I use useTestClasspath in my Jetty configuration : 不使用货运,我在码头配置中使用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>
Is there any way to configure Cargo with a kind of useTestClasspath ? 有什么方法可以用一种useTestClasspath配置Cargo吗? Thanks.
谢谢。
If I understand your question correctly, then your problem is, that some of your dependencies are in <scope>test</scope>
and thus they are not packaged to your war (or ear) file and will not be available in your integration (or other) tests, when working within the container. 如果我正确理解了您的问题,那么您的问题是,您的某些依赖项在
<scope>test</scope>
,因此它们没有打包到您的war(或ear)文件中,并且在您的集成中将不可用(或其他)测试(在容器内工作)。
To achieve that behaviour, you can add a dependency to the container definition just like you added the dependency to mysql-connector-java, what is missing in your config is the <type>
: 为了实现该行为,可以像在mysql-connector-java中添加依赖项一样向容器定义添加依赖项,配置中缺少的是
<type>
:
<container>
...
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<type>jar</type>
</dependency>
</dependencies>
</container>
Moreover that dependency's artfactId and groupId must resolve to a dependency that is already defined in your pom (as dependency). 而且,该依赖项的artfactId和groupId 必须解析为您pom中已定义的依赖项(作为依赖项)。 See here Cargo Maven2 Reference
参见此处Cargo Maven2参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.