Saturday, 15 September 2012

How to compile and run my Maven unit tests for Java 8, while having my code compiled for Java 7 -



How to compile and run my Maven unit tests for Java 8, while having my code compiled for Java 7 -

i want utilize java 8 syntax in unit tests. 'main' code must compiled java 7 since production environment has jdk 7 installed.

is there way of doing maven-compiler-plugin ? jenkins server has java 8 installed.

i take risk can accidental utilize java 8 specific functionality in production code.

in maven compile , testcompile goals different. , maven has parameters testcompile: testtarget , testsource. so:

<plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-compiler-plugin</artifactid> <version>3.0</version> <configuration> <source>1.7</source> <target>1.7</target> <testsource>1.8</testsource> <testtarget>1.8</testtarget> </configuration> </plugin>

java unit-testing maven junit jenkins

No comments:

Post a Comment