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
. Is there a way to do that in a single command -- without having to compile the entire project?
One idea is to have Maven generate the target/classpath.properties
file and then stop at that point.
The exec plugin provides another way to display the Maven generated classpath: $ mvn exec:exec -Dexec. executable=echo -Dexec. args="%classpath" [INFO] Scanning for projects...
Maven does set the classpath to the dependencies correctly, but not prefixed with repository location. It will look like this in your Manifest file. It is upto you to place the dependant jars in the same folder as the jar which you are running.
Description: This goal outputs a classpath string of dependencies from the local repository to a file or log.
To get the classpath all by itself in a file, you can:
mvn dependency:build-classpath -Dmdep.outputFile=cp.txt
Or add this to the POM.XML:
<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> <!-- configure the plugin here --> </configuration> </execution> </executions> </plugin> </plugins> </build> [...] </project>
From: http://maven.apache.org/plugins/maven-dependency-plugin/usage.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With