Java - Make src/main/java compile with java 1.4 and src/test/java compile with 1.5
I have a p开发者_如何学编程roject which must be compiled only with java 1.4. But I am planning to write some unit tests using mockito. I want a way to specify in pom so that src/main/java
compiles with jdk 1.4
but src/test/java
compiles with jdk 1.5
.
Is there a way to do this? If yes, what pom changes should be made?
Thanks for your time!!!
It is a rather strange set up. JDK 1.4 is ancient so I recommend you move to Java 6 if you can.
To answer your question you can use the testTarget parameter.
Example setup:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<testTarget>1.6</testTarget>
</configuration>
</plugin>
精彩评论