views:

29

answers:

2

Hi,

i'm trying to run a number of classes which reside in the Maven 'test' folder from the command line which i will later combine to run in a ksh script.

The issue i am having is that i can run files which are in the 'main' folder but i want to run another which is in the 'test' folder.

Does anyone know, or have any ideas as to how to do this???

cheers.

A: 

The test folder is reserved to unit tests. You can launch a single unit test with the following command:

$ mvn install -Dtest=ClassName

Note that ClassName doesn't include package name.

If you want to launch a class containing a main method, your class needs to be in the main folder.

Vivien Barousse
Interesting. I want to run a class which i don't want to be in the main folder but isn't recognised as a test as there is no @Test annotations in the class itself and there is no reason for it to have these but i would like to run it as a standalone and use the current version of the code it references from Maven, rather than just packaging it up into a JAR and running it that way. Any suggestions??
matt2010
@matt2010, take a look at the [exec-maven-plugin](http://mojo.codehaus.org/exec-maven-plugin/)
matt b
A: 

I've seen this now and i am wondering if either of these are the right things to be using??

<configuration>
          ..
      <classpathScope>test</classpathScope>
          ...
</configuration>

OR:

mvn exec:exec [...] -Dexec.classpathScope="java"

Could i replace "java" with "Test" and can i use exec:java instead or exec:exec??

matt2010
Did you try these? `mvn exec:java -Dexec.mainClass=your.class.name` should work, I use this regularly. If you need to include dependencies that are outside the usual scope then you can add `-Dexec.classPathScope=whatever-scope-you-need`.
matt b