For my current purposes I have a Maven project which creates a war
file, and I want to see what actual classpath it is using when creating the war
.
As ecerulm noted in his comment to Janik's answer, you may want to specify the scope to dependency:build-classpath
, as classpath output will differ for different scopes (by default test
is used for some reason). I've ended up with a command like this:
mvn -DincludeScope=compile dependency:build-classpath
Within the POM, it could be used like this:
<project>
[...]
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>build-classpath</id>
<phase>generate-sources</phase>
<goals>
<goal>build-classpath</goal>
</goals>
<configuration>
<includeScope>compile</includeScope>
<!-- Omit to print on console: -->
<outputFile>${project.build.directory}/compile-classpath.txt</outputFile>
</configuration>
</execution>
<execution>
<id>build-test-classpath</id>
<phase>generate-test-sources</phase>
<goals>
<goal>build-classpath</goal>
</goals>
<configuration>
<includeScope>test</includeScope>
<!-- Omit to print on console: -->
<outputFile>${project.build.directory}/test-classpath.txt</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
This will output 2 versions of classpath, one for main build and the other for tests.