[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!" ); 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" ); String modelVersion = (String) plugin.getConfiguration().get( "version" );
if ( modelVersion == null || modelVersion.trim().length() < 1 ) if ( modelVersion == null || modelVersion.trim().length() < 1 )
{ {

View File

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

View File

@ -64,6 +64,8 @@ public class ModelReader
private boolean insideDependencyManagement; private boolean insideDependencyManagement;
private boolean insideDistributionManagement; private boolean insideDistributionManagement;
private boolean insidePluginManagement;
private boolean insideReleases; private boolean insideReleases;
@ -141,6 +143,11 @@ public class ModelReader
insidePlugin = true; insidePlugin = true;
} }
else if ( rawName.equals( "pluginManagement" ) )
{
insidePluginManagement = true;
}
else if ( rawName.equals( "dependencyManagement" ) ) else if ( rawName.equals( "dependencyManagement" ) )
{ {
insideDependencyManagement = true; insideDependencyManagement = true;
@ -230,6 +237,7 @@ public class ModelReader
ProjectResolver.addDependencies( p.getManagedDependenciesCollection(), model.getManagedDependencies(), inheritedScope, Collections.EMPTY_SET ); ProjectResolver.addDependencies( p.getManagedDependenciesCollection(), model.getManagedDependencies(), inheritedScope, Collections.EMPTY_SET );
ProjectResolver.addPluginManagement( p.getManagedPluginsCollection(), model.getManagedPlugins() );
model.getRepositories().addAll( p.getRepositories() ); model.getRepositories().addAll( p.getRepositories() );
model.getResources().addAll( p.getResources() ); model.getResources().addAll( p.getResources() );
@ -279,8 +287,15 @@ public class ModelReader
} }
else if ( rawName.equals( "plugin" ) ) 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; insidePlugin = false;
} }
else if ( rawName.equals( "build" ) ) else if ( rawName.equals( "build" ) )

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 ) private static boolean hasDependency( Dependency d, Map dependencies )
{ {
String conflictId = d.getConflictId(); String conflictId = d.getConflictId();