With source / target, you only define javac switches, which means creating compatible code. For example, if you installed jdk 8 and want to create java 7 runable classes. But it does not check if JDK 8 is installed at all. This will also work if you have JDK 7 installed.
If you really need to check the version of the JDK that is installed, you need to go through the maven-enforcer-plugin and check the installed JDK ...
<project> [...] <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>1.4</version> <executions> <execution> <id>enforce-java</id> <goals> <goal>enforce</goal> </goals> <configuration> <rules> <requireJavaVersion> <version>1.8.0</version> </requireJavaVersion> </rules> </configuration> </execution> </executions> </plugin> </plugins> </build> [...] </project>
With the above, you can no longer build JDK 7 ... only with JDK 8 ...
BTW: Why are you using such an old version of maven-compiler-plugin ?
khmarbaise
source share