improved java version discovery algorithm with ideas taken from MPIR
git-svn-id: https://svn.apache.org/repos/asf/maven/plugin-tools/trunk@1647925 13f79535-47bb-0310-9956-ffa450edef68master
parent
9e1a66d448
commit
de5875e0af
|
|
@ -684,17 +684,12 @@ public class PluginReport
|
||||||
|
|
||||||
@SuppressWarnings( "unchecked" )
|
@SuppressWarnings( "unchecked" )
|
||||||
Plugin compiler = getCompilerPlugin( project.getBuild().getPluginsAsMap() );
|
Plugin compiler = getCompilerPlugin( project.getBuild().getPluginsAsMap() );
|
||||||
|
if ( compiler == null )
|
||||||
jdk = getTarget( compiler );
|
|
||||||
if ( jdk != null )
|
|
||||||
{
|
{
|
||||||
return jdk;
|
compiler = getCompilerPlugin( project.getPluginManagement().getPluginsAsMap() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings( "unchecked" )
|
jdk = getPluginParameter( compiler, "target" );
|
||||||
Plugin compilerManagement = getCompilerPlugin( project.getPluginManagement().getPluginsAsMap() );
|
|
||||||
|
|
||||||
jdk = getTarget( compilerManagement );
|
|
||||||
if ( jdk != null )
|
if ( jdk != null )
|
||||||
{
|
{
|
||||||
return jdk;
|
return jdk;
|
||||||
|
|
@ -707,12 +702,9 @@ public class PluginReport
|
||||||
return jdk;
|
return jdk;
|
||||||
}
|
}
|
||||||
|
|
||||||
String version = getVersion( compiler );
|
// return "1.5" by default?
|
||||||
|
|
||||||
if ( version == null )
|
String version = ( compiler == null ) ? null : compiler.getVersion();
|
||||||
{
|
|
||||||
version = getVersion( compilerManagement );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( version != null )
|
if ( version != null )
|
||||||
{
|
{
|
||||||
|
|
@ -724,17 +716,10 @@ public class PluginReport
|
||||||
|
|
||||||
private static Plugin getCompilerPlugin( Map<String, Object> pluginsAsMap )
|
private static Plugin getCompilerPlugin( Map<String, Object> pluginsAsMap )
|
||||||
{
|
{
|
||||||
for ( Map.Entry<String, Object> entry : pluginsAsMap.entrySet() )
|
return (Plugin) pluginsAsMap.get( "org.apache.maven.plugins:maven-compiler-plugin" );
|
||||||
{
|
|
||||||
if ( entry.getKey().equals( "org.apache.maven.plugins:maven-compiler-plugin" ) )
|
|
||||||
{
|
|
||||||
return (Plugin) entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTarget( Plugin plugin )
|
private static String getPluginParameter( Plugin plugin, String parameter )
|
||||||
{
|
{
|
||||||
if ( plugin != null )
|
if ( plugin != null )
|
||||||
{
|
{
|
||||||
|
|
@ -742,7 +727,7 @@ public class PluginReport
|
||||||
|
|
||||||
if ( pluginConf != null )
|
if ( pluginConf != null )
|
||||||
{
|
{
|
||||||
Xpp3Dom target = pluginConf.getChild( "target" );
|
Xpp3Dom target = pluginConf.getChild( parameter );
|
||||||
|
|
||||||
if ( target != null )
|
if ( target != null )
|
||||||
{
|
{
|
||||||
|
|
@ -753,15 +738,5 @@ public class PluginReport
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getVersion( Plugin plugin )
|
|
||||||
{
|
|
||||||
if ( plugin != null )
|
|
||||||
{
|
|
||||||
return plugin.getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue