Maven WAR dependency

deelo55 picture deelo55 · Nov 20, 2009 · Viewed 80.8k times · Source

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.

Answer

Christoph Leiter picture Christoph Leiter · Apr 10, 2012

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>