[MNG-2447] fix the bootstrap by adding plugin management support for modello since the versions were rationalised

Submitted by: Pete Marvin King


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@422081 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2006-07-14 22:32:29 +00:00
parent 23f64db797
commit fbd4214e1d
4 changed files with 56 additions and 2 deletions

View File

@ -322,6 +322,20 @@ public class Bootstrap
System.out.println( "Model exists!" );
// acquire the version from the parent pom pluginManagement
String version = plugin.getVersion();
if ( ( version == null ) || ( version == "" ) )
{
Plugin managedPlugin = (Plugin) model.getManagedPlugins().get( MODELLO_PLUGIN_ID );
if ( managedPlugin == null )
{
throw new Exception( "can not determine version of " + MODELLO_PLUGIN_ID );
}
plugin.setVersion( managedPlugin.getVersion() );
}
String modelVersion = (String) plugin.getConfiguration().get( "version" );
if ( modelVersion == null || modelVersion.trim().length() < 1 )
{

View File

@ -65,6 +65,8 @@ public class Model
private Map managedDependencies = new HashMap();
private Map managedPlugins = new HashMap();
private List chain;
public Model()
@ -224,6 +226,19 @@ public class Model
return m.values();
}
public Map getManagedPlugins()
{
return managedPlugins;
}
public Collection getManagedPluginsCollection()
{
Map m = new HashMap();
m.putAll( managedPlugins );
return m.values();
}
public String toString()
{
return "Model[" + getId() + "]";

View File

@ -65,6 +65,8 @@ public class ModelReader
private boolean insideDistributionManagement;
private boolean insidePluginManagement;
private boolean insideReleases;
private boolean insideSnapshots;
@ -141,6 +143,11 @@ public class ModelReader
insidePlugin = true;
}
else if ( rawName.equals( "pluginManagement" ) )
{
insidePluginManagement = true;
}
else if ( rawName.equals( "dependencyManagement" ) )
{
insideDependencyManagement = true;
@ -230,6 +237,7 @@ public class ModelReader
ProjectResolver.addDependencies( p.getManagedDependenciesCollection(), model.getManagedDependencies(), inheritedScope, Collections.EMPTY_SET );
ProjectResolver.addPluginManagement( p.getManagedPluginsCollection(), model.getManagedPlugins() );
model.getRepositories().addAll( p.getRepositories() );
model.getResources().addAll( p.getResources() );
@ -278,8 +286,15 @@ public class ModelReader
insideRepository = false;
}
else if ( rawName.equals( "plugin" ) )
{
if (insidePluginManagement)
{
model.getManagedPlugins().put( currentPlugin.getId(), currentPlugin );
}
else
{
model.getPlugins().put( currentPlugin.getId(), currentPlugin );
}
insidePlugin = false;
}

View File

@ -116,6 +116,16 @@ public final class ProjectResolver
}
}
public static void addPluginManagement( Collection plugins, Map target)
{
Plugin managedPlugin;
for (Iterator i = plugins.iterator(); i.hasNext(); )
{
managedPlugin = (Plugin) i.next();
target.put(managedPlugin.getId(),managedPlugin);
}
}
private static boolean hasDependency( Dependency d, Map dependencies )
{
String conflictId = d.getConflictId();