You can also use the property "jvm" in the surefire configuration to specify the path to the jvm you want to use to execute your tests.
http://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm Am Donnerstag, 2. Mai 2013 schrieb Stephen Connolly : > On Thursday, 2 May 2013, Jean Tremblay wrote: > > > Hi, > > > > I have a bit of a complicated setup. I need to build my jar file using > > java 1.6, but I need to execute my tests using Java 1.7, as my library > need > > to connect to other libraries built for Java V1.7. > > How can I do that? > > > > I currently set my pom.xml with the following entries: > > > > <properties> > > <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> > > <maven.compiler.target>1.6</maven.compiler.target> > > <maven.compiler.source>1.6</maven.compiler.source> > > </properties> > > > > > > > > Unfortunately when my test is executed it is also running using v1.6 but > I > > would like to use version 1.7. > > > > Is there a way to tell sure fire (I guess this is the plugin I should > look > > at) to use v1.7 when executing the tests? > > What is exactly choosing the target version of the Java being used for > > testing? > > > > I develop my project library using eclipse. I have set this project to > use > > java 1.6 for this eclipse project. If I tell eclipse to use V1.7 my tests > > are executed in Maven using V1.7 and then my test are all fine. The > problem > > is then that when I build my jar files there are conflicts between the > java > > used by eclipse and the java used by Maven, and it can happen that > suddenly > > the jar file is built with java classes being 1.7 instead of 1.6. > > > > Does anyone have an idea what I should do here? > > > See my answer here: > > http://stackoverflow.com/questions/12414209/compile-maven-module-with-different-java-version/12419643#12419643 > > IIRC you then need to bind a second execution of tool chains after the > compile phase but before the test phase to switch to 1.7 > > > > > Thanks for your help. > > > > Jean > > > > > -- > Sent from my phone >
