I developed and built my Java application using Maven. I need to support Java 1.6, so I use the following properties:
1.6
The problem is that every dependency (maintainer) can decide on it's own which java version is used to compile (1.5, 1.6, 1.7, 1.8 etc) so this is not solvable via Maven. But you can make sure that you don't use dependencies which are using a different Java version than you like to have.
This can be enfored by using Maven Enforcer Plugin by using extra-enforcer-rules:
[...]
org.apache.maven.plugins
maven-enforcer-plugin
1.4.1
enforce-bytecode-version
enforce
1.6
org.mindrot:jbcrypt
true
org.codehaus.mojo
extra-enforcer-rules
1.0-beta-5
[...]
This will break your build if you have a dependency which is compiled with a different version of JDK than you want to have.