I have a project that uses "system" scope to specify a jar file included in my project's WEB-INF/lib
dir. This artifact is not in any of the maven repositories, so I must include it as part of my project. I do so with the following:
<dependency>
<groupId>com.example</groupId>
<artifactId>MySpecialLib</artifactId>
<version>1.2</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/MySpecialLib-1.2.jar</systemPath>
</dependency>
This has worked great for most things.
But now I'm trying to run some code on the command line (outside of my webapp, via a main()
method I have added) and mvn exec:java
can't resolve code in MySpecialLib because it's not included in the "runtime" classpath.
How can I either:
or
mvn exec:java
to also use the system
classpath ?I've tried mvn exec:java -Dexec.classpathScope=system
, but that leaves off everything that's on runtime
.
When Maven's Surefire plugin executes unit tests of a project, developers do not need to provide the classpath containing all dependencies. Instead, Maven sets up the required classpath. Other plugins utilize the Maven generated classpath, too.
Usage of a Maven Plugin xml you can use the shorthand notation to execute the plugin: mvn <prefix>:<goal> , commonly the “prefix” is the artifact ID minus the “-maven-plugin”.
mvn exec:java is a goal from the exec plugin for maven. It lets you specify a main class to execute (see pom. xml). This lets you avoid having to figure out the proper java command to run and classpath arguments and the like.
Use 'compile' scope to run maven exec plugin - mvn exec:java -Dexec.classpathScope=compile
. This will include system-scoped dependencies.
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