The Exec plugin makes it possible for us to run the simplest weather program without having to load
the appropriate dependencies into the classpath. In any other build system, we would have to copy all of the program dependencies into some sort of lib/ directory containing a collection of JAR files. Then,
we would have to write a simple script that includes our program’s bytecode and all of our dependencies
in a classpath. Only then could we run java org.sonatype.mavenbook.weather.Main. The
Exec plugin leverages the fact that Maven already knows how to create and manage your classpath and
dependencies.
mvn exec:java -Dexec.mainClass=org.sonatype.mavenbook.weather.Main \ -Dexec.args="70112"
This is convenient, but it’s also nice to know exactly what is being included in your project’s classpath.
Although the project depends on a few libraries such as Dom4J, Log4J, Jaxen, and Velocity, it also relies
on a few transitive dependencies. If you need to find out what is on the classpath, you can use the Maven
Dependency plugin to print out a
mvn dependency:resolve
mvn dependency:resolve
mvn dependency:tree
No comments:
Post a Comment