private static String findJavaVersionString ( MavenProject project ) { while ( project != null ) { String target = project . getProperties ( ) . getProperty ( "maven.compiler.target" ) ; if ( target != null ) { return target ; } for ( org . apache . maven . model . Plugin plugin : CompoundList . of ( project . getBuildPlugins ( ) , project . getPluginManagement ( ) . getPlugins ( ) ) ) { if ( "maven-compiler-plugin" . equals ( plugin . getArtifactId ( ) ) ) { if ( plugin . getConfiguration ( ) instanceof Xpp3Dom ) { Xpp3Dom node = ( ( Xpp3Dom ) plugin . getConfiguration ( ) ) . getChild ( "target" ) ; if ( node != null ) { return node . getValue ( ) ; } } } } project = project . getParent ( ) ; } return null ; }
Makes a best effort of locating the configured Java target version .