mirror of https://github.com/apache/maven.git
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:
parent
bd743a5c30
commit
60f9555333
|
@ -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
|
||||
|
|
|
@ -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"/>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.apache.maven.plugin.loader.PluginLoaderException;
|
|||
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.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
|
@ -44,10 +44,9 @@ import java.util.StringTokenizer;
|
|||
public class DefaultLifecycleBindingManager
|
||||
implements LifecycleBindingManager, LogEnabled
|
||||
{
|
||||
private Map bindingsByPackaging;
|
||||
|
||||
private ActiveMap bindingsByPackaging;
|
||||
|
||||
private ActiveMap legacyMappingsByPackaging;
|
||||
private Map legacyMappingsByPackaging;
|
||||
|
||||
private PluginLoader pluginLoader;
|
||||
|
||||
|
|
|
@ -348,6 +348,7 @@ public class DefaultPluginManager
|
|||
ClassRealm pluginRealm = null;
|
||||
|
||||
MavenProjectSession projectSession;
|
||||
|
||||
try
|
||||
{
|
||||
projectSession = session.getProjectSession( project );
|
||||
|
@ -414,6 +415,7 @@ public class DefaultPluginManager
|
|||
try
|
||||
{
|
||||
getLogger().debug( "Discovering components in realm: " + pluginRealm );
|
||||
|
||||
container.discoverComponents( pluginRealm, false );
|
||||
}
|
||||
catch ( PlexusConfigurationException e )
|
||||
|
@ -1423,9 +1425,8 @@ public class DefaultPluginManager
|
|||
|
||||
if ( pluginRealm == null )
|
||||
{
|
||||
getLogger().warn(
|
||||
"getPluginComponent(" + plugin + ", " + role
|
||||
+ "): descriptor is missing classRealm" );
|
||||
getLogger().warn( "getPluginComponent(" + plugin + ", " + role + "): descriptor is missing classRealm" );
|
||||
|
||||
pluginRealm = container.getLookupRealm();
|
||||
}
|
||||
|
||||
|
|
|
@ -33,10 +33,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
public class MavenPluginCollector
|
||||
extends AbstractLogEnabled
|
||||
implements ComponentDiscoveryListener
|
||||
{
|
||||
|
||||
private Set pluginsInProcess = new HashSet();
|
||||
|
||||
private Map pluginDescriptors = new HashMap();
|
||||
|
@ -56,13 +54,11 @@ public class MavenPluginCollector
|
|||
|
||||
// TODO: see comment in getPluginDescriptor
|
||||
String key = Plugin.constructKey( pluginDescriptor.getGroupId(), pluginDescriptor.getArtifactId() );
|
||||
|
||||
|
||||
if ( !pluginsInProcess.contains( key ) )
|
||||
{
|
||||
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
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.codehaus.plexus.configuration.PlexusConfigurationException;
|
|||
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øl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -45,6 +45,8 @@ import org.apache.maven.model.Plugin;
|
|||
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 @@ public class MavenEmbedder
|
|||
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 @@ public class MavenEmbedder
|
|||
|
||||
try
|
||||
{
|
||||
map.putAll( getPluginExtensionComponents( plugin ) );
|
||||
Map extensionComponents = getPluginExtensionComponents( plugin );
|
||||
|
||||
map.putAll( extensionComponents );
|
||||
}
|
||||
catch ( PluginManagerException e )
|
||||
{
|
||||
|
@ -406,6 +412,7 @@ public class MavenEmbedder
|
|||
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 class MavenEmbedder
|
|||
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 class MavenEmbedder
|
|||
|
||||
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 class MavenEmbedder
|
|||
return result;
|
||||
}
|
||||
|
||||
MavenProjectBuildingResult projectBuildingResult = null;
|
||||
MavenProjectBuildingResult projectBuildingResult;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -633,7 +645,9 @@ public class MavenEmbedder
|
|||
|
||||
try
|
||||
{
|
||||
ContainerConfiguration cc = new DefaultContainerConfiguration()
|
||||
ContainerConfiguration cc = new DefaultContainerConfiguration()
|
||||
.addComponentDiscoverer( new MavenPluginDiscoverer() )
|
||||
.addComponentDiscoveryListener( new MavenPluginCollector() )
|
||||
.setClassWorld( classWorld ).setParentContainer( configuration.getParentContainer() ).setName( "embedder" );
|
||||
|
||||
container = new DefaultPlexusContainer( cc );
|
||||
|
|
|
@ -49,8 +49,11 @@ public class MavenEmbedderProjectWithExtensionReadingTest
|
|||
throws PluginManagerException
|
||||
{
|
||||
Map toReturn = new HashMap();
|
||||
|
||||
MyArtifactHandler handler = new MyArtifactHandler();
|
||||
|
||||
toReturn.put( "mkleint", handler );
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ under the License.
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.ArtifactFilterManager</role>
|
||||
<implementation>org.apache.maven.DefaultArtifactFilterManager</implementation>
|
||||
|
@ -110,8 +110,8 @@ under the License.
|
|||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
<role-hint>default</role-hint>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
<role-hint>default</role-hint>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
@ -538,25 +538,7 @@ under the License.
|
|||
</requirement>
|
||||
</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>
|
||||
|
@ -576,7 +558,7 @@ under the License.
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.binding.LifecycleBindingManager</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>
|
||||
|
@ -675,7 +655,7 @@ under the License.
|
|||
<!-- END SNIPPET: default-reports -->
|
||||
</configuration>
|
||||
</component>
|
||||
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.plan.BuildPlanner</role>
|
||||
<role-hint>default</role-hint>
|
||||
|
@ -692,7 +672,7 @@ under the License.
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.binding.MojoBindingFactory</role>
|
||||
<role-hint>default</role-hint>
|
||||
|
@ -703,7 +683,7 @@ under the License.
|
|||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.binding.LegacyLifecycleMappingParser</role>
|
||||
<role-hint>default</role-hint>
|
||||
|
@ -714,6 +694,19 @@ under the License.
|
|||
</requirement>
|
||||
</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>
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -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>
|
||||
|
@ -269,4 +269,4 @@ under the License.
|
|||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue