Search code examples
javamavenm2eclipse

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. I have built a client library and bundled all its classes in a JAR.

I would like to test the client library against the 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. How should I do ?

Eclipse Indigo
JDK 6
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.


Solution

  • This depends on what tests you need to run from your client.jar to the server.war file

    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. This would overlay the war into your test-war module.

    If you dont need the war file but dependencies of it (service layer classes) i would only include those for testing.