问题
what options to maven can I use to determine what classpath maven is running a testng test case with?
回答1:
You didn't provide the Maven version, but at least in 3.x (and maybe also 2.x) you can run commands with the -X (debug) option. That way the Test Classpath is printed out before tests are run.
mvn test -X
回答2:
In general you can find the classpath that maven is using by using the built-in maven dependency plugin and its build-classpath goal.
If you want the classpath uses for compiling and running the test you need to select the test
dependency scope. This scope is the default, but if you want to be explicit you can set it with -DincludeScope=test
.
Other scopes include runtime
, compile
, provided
and system
.
Depending on how you want to consume the output you can play with the options -Dmdep.outputFilterFile
and -Dmdep.outputFile
. The mdep.outputFilterFile
makes it easier to parse the output from a script and the outputFile
option writes to a file instead which some tools can read directly.
Here are some examples:
$ mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFilterFile=true|grep 'classpath='
classpath=xxx.jar:yyy.jar
$ mvn dependency:build-classpath -DincludeScope=test -Dmdep.outputFile=cp.txt
$ cat cp.txt
xxx.jar:yyy.jar
回答3:
I couldn't format my response in my comment so submitting the grepped version here:
mvn test -X | grep "maven.dependency.classpath"
来源:https://stackoverflow.com/questions/7898875/find-classpath-maven-is-using-for-running-testng-testcase