Maven WAR dependency

mavenmaven-2maven-dependency-pluginwar

I am writing a project for acceptance testing and for various reasons this is dependent on another project which is packaged as a WAR. I have managed to unpack the WAR using the maven-dependency-plugin, but I cannot get my project to include the unpacked WEB-INF/lib/*.jar and WEB-INF/classes/* to be included on the classpath so the build fails. Is there a way to include these files into the classpath, or is there a better way of depending on a WAR?

Many thanks.

Best Answer

There's another option since maven-war-plugin 2.1-alpha-2. In your WAR project:

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.1.1</version>
    <configuration>
        <attachClasses>true</attachClasses>
    </configuration>
</plugin>

This creates a classes artifact which you can use in the acceptance tests project with:

<dependency>
    <groupId>your-group-id</groupId>
    <artifactId>your-artifact-id</artifactId>
    <version>your-version</version>
    <classifier>classes</classifier>
</dependency>