views:

210

answers:

2

Setup I'm packaging a WAR with a number of legacy jar dependencies in it (for the sake of keeping this simple, they can not possibly be altered or excluded from the deployed WAR).

Issue Including either or both of two of these jars will cause inexorable errors at test-time. If I exclude the dependencies altogether, the tests pass happily, but the WAR will lack real-world runtime classes it needs.

Hope Maven2 offers compile, test, runtime, system, and provided scopes. Sadly, none of these will be included in the assembly but kept off the test classpath. My hope is that I'm missing some obvious way to handle this case entirely within the dependency management feature.

Fear I'll have to use the assembly plugin to copy these problem jars into the target. I don't want to have to skirt the dependency management system to copy jars in the clear into the target, as I don't want to manage these jars outside the internal repository.

Thoughts? Alternatives?

+1  A: 

Of course it figures that I'd come across a potential solution to this moments after posting a question. It appears that the copy goal of the dependency plugin may handle this. Going to try this out now: http://maven.apache.org/plugins/maven-dependency-plugin/usage.html

Edit: Turns out that this worked fine for my needs, snippet below:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
     <execution>
      <phase>prepare-package</phase>
      <goals>
       <goal>copy</goal>
      </goals>
     </execution>
    </executions>
    <configuration>
     <artifactItems>
      <artifactItem>
       <groupId>group</groupId>
       <artifactId>artifact</artifactId>
       <version>version</version>
       <type>jar</type>
       <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
      </artifactItem>
     </artifactItems>
    </configuration>
</plugin>
Justin Searls
A: 

Break the test classes out of the jar file into a separate jar which is only for tests, and add an exclusion to the dependency on the jar with the legacy dependencies.

Jherico