[英]How can I tell Maven to add the dependencies of my war on the test classpath?
I have built a set of servlets and bundled them all in a WAR. 我构建了一组servlet,并将它们全部捆绑在WAR中。 I have built a client library and bundled all its classes in a JAR. 我建立了一个客户端库并将其所有类捆绑在一个JAR中。
I would like to test the client library against the WAR. 我想针对WAR测试客户端库。 I tried this : 我尝试了这个:
<dependency>
<groupId>com.company.myproject</groupId>
<artifactId>the-war-of-myproject</artifactId>
<version>1.1.0</version>
<type>war</type>
<scope>test</scope>
</dependency>
Unfortunately, it's not possible to add a WAR as a dependency in a pom.xml. 不幸的是,不可能在pom.xml中添加WAR作为依赖项。 How should I do ? 我应该怎么做 ?
Eclipse Indigo 日食靛蓝
JDK 6 JDK 6
Maven 3 Maven 3
EDIT: 编辑:
Based on wemu's comment, I have decided to move the classes required by both the WAR and the JAR into a common dependency. 根据wemu的评论,我决定将WAR和JAR都需要的类移到一个公共依赖项中。
This depends on what tests you need to run from your client.jar to the server.war file 这取决于需要从client.jar到server.war文件运行哪些测试
You could create a 3rd project, add both client.jar and server.war as a dependency and use the war packageing too for this test-module. 您可以创建第三个项目,将client.jar和server.war都添加为依赖项,并对该测试模块也使用war打包。 This would overlay the war into your test-war module. 这会将战争叠加到您的test-war模块中。
If you dont need the war file but dependencies of it (service layer classes) i would only include those for testing. 如果您不需要war文件,但需要它的依赖项(服务层类),那么我将只包括那些用于测试的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.