简体   繁体   English

我如何告诉Maven在测试类路径上添加我的战争依赖项?

[英]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.

相关问题 如何在运行时类路径上具有Maven依赖性而不是测试类路径? - How can I have a Maven dependency on the runtime classpath but not the test classpath? 如何判断哪个maven依赖项负责包含我的WAR文件中包含的jar? - How can I tell which maven dependency is responsible for including jars included in my WAR file? Maven如何将可传递依赖项添加到类路径中? - How does maven add transitive dependencies into classpath? 如何使用SublimeLinter-javac将Gradle管理的依赖项添加到我的类路径中? - How can I add Gradle managed dependencies to my classpath using SublimeLinter-javac? 将Maven依赖项添加到Weblogic类路径 - Add maven dependencies to weblogic classpath 我怎样才能将文件添加到类路径而不是使用Maven的jar中? - How can I add a file to a classpath but not to a jar with maven? 如何编写maven build来为classpath添加资源? - How can I write maven build to add resources to classpath? Eclipse 运行配置:如何添加已添加到 Classpath 的项目的 Maven 依赖项 - Eclipse Run Configurations: how to add Maven dependencies of projects added to Classpath 我可以为不同的WAR插件执行添加额外的Maven依赖项吗 - Can I drag in extra Maven dependencies for different WAR plugin executions 如何将类路径添加到maven - How to add classpath to maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM