o use the programmatic setup of the container

o use the new active collections in Pleuxus


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@587015 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2007-10-22 07:07:29 +00:00
parent bd743a5c30
commit 60f9555333
13 changed files with 56 additions and 88 deletions

View File

@ -16,8 +16,7 @@
# under the License.
classworlds.version=1.2-alpha-10
plexus-active-collections.version=1.0-beta-1
plexus.version=1.0-alpha-32
plexus.version=1.0-alpha-34-SNAPSHOT
plexus-utils.version=1.4.5
maven-artifact.version=3.0-SNAPSHOT
commons-cli.version=1.0

View File

@ -116,7 +116,6 @@ under the License.
</sequential>
</macrodef>
<pull orgpath="commons-cli/commons-cli" version="${commons-cli.version}" name="commons-cli"/>
<pull orgpath="org/codehaus/plexus/plexus-active-collections" version="${plexus-active-collections.version}" name="plexus-active-collections" repository="codehaus"/>
<pull orgpath="org/codehaus/plexus/plexus-utils" version="${plexus-utils.version}" name="plexus-utils" repository="codehaus"/>
<pull orgpath="org/codehaus/plexus/plexus-container-default" version="${plexus.version}" name="plexus-container-default" repository="codehaus"/>
<pull orgpath="org/codehaus/plexus/plexus-classworlds" version="${classworlds.version}" name="plexus-classworlds" repository="codehaus"/>
@ -143,7 +142,6 @@ under the License.
<path id="pre.classpath">
<pathelement location="${maven.repo.local}/commons-cli/commons-cli/${commons-cli.version}/commons-cli-${commons-cli.version}.jar"/>
<pathelement location="${maven.repo.local}/commons-lang/commons-lang/${commons-lang.version}/commons-lang-${commons-lang.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-active-collections/${plexus-active-collections.version}/plexus-active-collections-${plexus-active-collections.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-utils/${plexus-utils.version}/plexus-utils-${plexus-utils.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-container-default/${plexus.version}/plexus-container-default-${plexus.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-classworlds/${classworlds.version}/plexus-classworlds-${classworlds.version}.jar"/>

View File

@ -111,11 +111,6 @@ under the License.
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-classworlds</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-active-collections</artifactId>
<version>1.0-beta-1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>

View File

@ -20,7 +20,6 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReport;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.collections.ActiveMap;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
@ -31,6 +30,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
/**
@ -44,10 +44,9 @@
public class DefaultLifecycleBindingManager
implements LifecycleBindingManager, LogEnabled
{
private Map bindingsByPackaging;
private ActiveMap bindingsByPackaging;
private ActiveMap legacyMappingsByPackaging;
private Map legacyMappingsByPackaging;
private PluginLoader pluginLoader;

View File

@ -348,6 +348,7 @@ protected void addPlugin( Plugin plugin,
ClassRealm pluginRealm = null;
MavenProjectSession projectSession;
try
{
projectSession = session.getProjectSession( project );
@ -414,6 +415,7 @@ protected void addPlugin( Plugin plugin,
try
{
getLogger().debug( "Discovering components in realm: " + pluginRealm );
container.discoverComponents( pluginRealm, false );
}
catch ( PlexusConfigurationException e )
@ -1423,9 +1425,8 @@ public Map getPluginComponents( Plugin plugin,
if ( pluginRealm == null )
{
getLogger().warn(
"getPluginComponent(" + plugin + ", " + role
+ "): descriptor is missing classRealm" );
getLogger().warn( "getPluginComponent(" + plugin + ", " + role + "): descriptor is missing classRealm" );
pluginRealm = container.getLookupRealm();
}

View File

@ -33,10 +33,8 @@
import java.util.Set;
public class MavenPluginCollector
extends AbstractLogEnabled
implements ComponentDiscoveryListener
{
private Set pluginsInProcess = new HashSet();
private Map pluginDescriptors = new HashMap();
@ -61,8 +59,6 @@ public void componentDiscovered( ComponentDiscoveryEvent event )
{
pluginsInProcess.add( key );
getLogger().debug( this + ": Discovered plugin: " + key );
pluginDescriptors.put( key, pluginDescriptor );
// TODO: throw an (not runtime) exception if there is a prefix overlap - means doing so elsewhere

View File

@ -27,7 +27,7 @@
import java.io.Reader;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @author Jason van Zyl
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id$
*/

View File

@ -539,24 +539,6 @@ under the License.
</requirements>
</component>
<component>
<role>org.codehaus.plexus.collections.ActiveMap</role>
<role-hint>lifecycle-loaders-by-packaging</role-hint>
<implementation>org.codehaus.plexus.collections.DefaultActiveMap</implementation>
<configuration>
<role>org.apache.maven.lifecycle.LifecycleBindingLoader</role>
</configuration>
</component>
<component>
<role>org.codehaus.plexus.collections.ActiveMap</role>
<role-hint>legacy-lifecycle-mappings-by-packaging</role-hint>
<implementation>org.codehaus.plexus.collections.DefaultActiveMap</implementation>
<configuration>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
</configuration>
</component>
<component>
<role>org.apache.maven.plugin.loader.PluginLoader</role>
<role-hint>default</role-hint>
@ -586,13 +568,11 @@ under the License.
<role>org.apache.maven.plugin.loader.PluginLoader</role>
</requirement>
<requirement>
<role>org.codehaus.plexus.collections.ActiveMap</role>
<role-hint>lifecycle-loaders-by-packaging</role-hint>
<role>org.apache.maven.lifecycle.LifecycleBindingLoader</role>
<field-name>bindingsByPackaging</field-name>
</requirement>
<requirement>
<role>org.codehaus.plexus.collections.ActiveMap</role>
<role-hint>legacy-lifecycle-mappings-by-packaging</role-hint>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<field-name>legacyMappingsByPackaging</field-name>
</requirement>
<requirement>

View File

@ -18,16 +18,6 @@ under the License.
-->
<plexus>
<component-discoverer-manager implementation="org.codehaus.plexus.component.discovery.DefaultComponentDiscovererManager">
<listeners>
<listener implementation="org.codehaus.plexus.component.discovery.DiscoveryListenerDescriptor">
<role>org.apache.maven.plugin.MavenPluginCollector</role>
</listener>
</listeners>
<component-discoverers>
<component-discoverer implementation="org.apache.maven.plugin.MavenPluginDiscoverer"/>
</component-discoverers>
</component-discoverer-manager>
<components>
<component>
<role>org.apache.maven.plugin.MavenPluginCollector</role>

View File

@ -45,6 +45,8 @@
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.plugin.InvalidPluginException;
import org.apache.maven.plugin.MavenPluginCollector;
import org.apache.maven.plugin.MavenPluginDiscoverer;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
@ -329,11 +331,13 @@ protected Map getPluginExtensionComponents( Plugin plugin )
try
{
PluginManager pluginManager = (PluginManager) container.lookup( PluginManager.ROLE );
return pluginManager.getPluginComponents( plugin, ArtifactHandler.ROLE );
}
catch ( ComponentLookupException e )
{
getLogger().debug( "Unable to find the lifecycle component in the extension", e );
return new HashMap();
}
}
@ -395,7 +399,9 @@ private Map findArtifactTypeHandlers( MavenProject project )
try
{
map.putAll( getPluginExtensionComponents( plugin ) );
Map extensionComponents = getPluginExtensionComponents( plugin );
map.putAll( extensionComponents );
}
catch ( PluginManagerException e )
{
@ -406,6 +412,7 @@ private Map findArtifactTypeHandlers( MavenProject project )
for ( Iterator j = map.values().iterator(); j.hasNext(); )
{
ArtifactHandler handler = (ArtifactHandler) j.next();
if ( project.getPackaging().equals( handler.getPackaging() ) )
{
project.getArtifact().setArtifactHandler( handler );
@ -425,9 +432,11 @@ public MavenProject readProject( File mavenProject )
throws ProjectBuildingException, ExtensionScanningException
{
getLogger().info( "Scanning for extensions: " + mavenProject );
extensionScanner.scanForBuildExtensions( mavenProject, request.getLocalRepository(), request.getProfileManager(), new HashMap() );
getLogger().info( "Building MavenProject instance: " + mavenProject );
return mavenProjectBuilder.build( mavenProject, request.getLocalRepository(), request.getProfileManager() );
}
@ -462,6 +471,9 @@ public MavenExecutionResult readProjectWithDependencies( MavenExecutionRequest r
Map handlers = findArtifactTypeHandlers( project );
//TODO: ok this is crappy, now there are active collections so when new artifact handlers
// enter the system they should be available.
artifactHandlerManager.addHandlers( handlers );
}
catch ( MavenEmbedderException e )
@ -484,7 +496,7 @@ public MavenExecutionResult readProjectWithDependencies( MavenExecutionRequest r
return result;
}
MavenProjectBuildingResult projectBuildingResult = null;
MavenProjectBuildingResult projectBuildingResult;
try
{
@ -634,6 +646,8 @@ private void start( Configuration configuration )
try
{
ContainerConfiguration cc = new DefaultContainerConfiguration()
.addComponentDiscoverer( new MavenPluginDiscoverer() )
.addComponentDiscoveryListener( new MavenPluginCollector() )
.setClassWorld( classWorld ).setParentContainer( configuration.getParentContainer() ).setName( "embedder" );
container = new DefaultPlexusContainer( cc );

View File

@ -49,8 +49,11 @@ protected Map getPluginExtensionComponents( Plugin plugin )
throws PluginManagerException
{
Map toReturn = new HashMap();
MyArtifactHandler handler = new MyArtifactHandler();
toReturn.put( "mkleint", handler );
return toReturn;
}

View File

@ -539,24 +539,6 @@ under the License.
</requirements>
</component>
<component>
<role>org.codehaus.plexus.collections.ActiveMap</role>
<role-hint>lifecycle-loaders-by-packaging</role-hint>
<implementation>org.codehaus.plexus.collections.DefaultActiveMap</implementation>
<configuration>
<role>org.apache.maven.lifecycle.LifecycleBindingLoader</role>
</configuration>
</component>
<component>
<role>org.codehaus.plexus.collections.ActiveMap</role>
<role-hint>legacy-lifecycle-mappings-by-packaging</role-hint>
<implementation>org.codehaus.plexus.collections.DefaultActiveMap</implementation>
<configuration>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
</configuration>
</component>
<component>
<role>org.apache.maven.plugin.loader.PluginLoader</role>
<role-hint>default</role-hint>
@ -586,12 +568,10 @@ under the License.
<role>org.apache.maven.plugin.loader.PluginLoader</role>
</requirement>
<requirement>
<role>org.codehaus.plexus.collections.ActiveMap</role>
<role-hint>lifecycle-loaders-by-packaging</role-hint>
<field-name>bindingsByPackaging</field-name>
</requirement>
<requirement>
<role>org.codehaus.plexus.collections.ActiveMap</role>
<role-hint>legacy-lifecycle-mappings-by-packaging</role-hint>
<field-name>legacyMappingsByPackaging</field-name>
</requirement>
@ -715,5 +695,18 @@ under the License.
</requirements>
</component>
<component>
<role>org.apache.maven.settings.validation.SettingsValidator</role>
<implementation>org.apache.maven.settings.validation.DefaultSettingsValidator</implementation>
</component>
<component>
<role>org.apache.maven.settings.MavenSettingsBuilder</role>
<implementation>org.apache.maven.settings.DefaultMavenSettingsBuilder</implementation>
<requirements>
<requirement>
<role>org.apache.maven.settings.validation.SettingsValidator</role>
</requirement>
</requirements>
</component>
</components>
</component-set>

View File

@ -131,7 +131,7 @@ under the License.
<module>maven-embedder</module>
</modules>
<properties>
<plexusVersion>1.0-alpha-32</plexusVersion>
<plexusVersion>1.0-alpha-34-SNAPSHOT</plexusVersion>
<wagonVersion>1.0-beta-2</wagonVersion>
</properties>
<dependencies>