[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 @@ private File buildProject( Model model )
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 Collection getManagedDependenciesCollection()
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

@ -64,6 +64,8 @@ public class ModelReader
private boolean insideDependencyManagement;
private boolean insideDistributionManagement;
private boolean insidePluginManagement;
private boolean insideReleases;
@ -141,6 +143,11 @@ else if ( rawName.equals( "plugin" ) )
insidePlugin = true;
}
else if ( rawName.equals( "pluginManagement" ) )
{
insidePluginManagement = true;
}
else if ( rawName.equals( "dependencyManagement" ) )
{
insideDependencyManagement = true;
@ -230,6 +237,7 @@ public void endElement( String uri, String localName, String rawName )
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() );
@ -279,8 +287,15 @@ else if ( rawName.equals( "repository" ) )
}
else if ( rawName.equals( "plugin" ) )
{
model.getPlugins().put( currentPlugin.getId(), currentPlugin );
if (insidePluginManagement)
{
model.getManagedPlugins().put( currentPlugin.getId(), currentPlugin );
}
else
{
model.getPlugins().put( currentPlugin.getId(), currentPlugin );
}
insidePlugin = false;
}
else if ( rawName.equals( "build" ) )

View File

@ -116,6 +116,16 @@ public static void addDependencies( Collection dependencies, Map target, String
}
}
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();