o the component discovery is not exposed outside the plexus core

git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@768721 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-04-26 16:34:19 +00:00
parent 5d7758b358
commit 755afec417
13 changed files with 49 additions and 65 deletions

View File

@ -44,7 +44,6 @@ public class DefaultUpdateCheckManager
extends AbstractLogEnabled
implements UpdateCheckManager
{
public DefaultUpdateCheckManager()
{
@ -75,6 +74,8 @@ public boolean isUpdateRequired( Artifact artifact, ArtifactRepository repositor
// release-artifact short circuit above.
ArtifactRepositoryPolicy policy = repository.getSnapshots();
System.out.println( "snappies " + repository.getSnapshots().getUpdatePolicy() );
return isUpdateRequired( artifact, repository, policy );
}

View File

@ -93,7 +93,7 @@ public class DefaultWagonManager
private ArtifactRepositoryFactory repositoryFactory;
@Requirement(role = Wagon.class)
private Map wagons;
private Map<String,Wagon> wagons;
//@Requirement
private CredentialsDataSource credentialsDataSource;
@ -324,11 +324,6 @@ public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepos
public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepositories, TransferListener downloadMonitor, boolean force )
throws TransferFailedException, ResourceDoesNotExistException
{
if(remoteRepositories == null)
{
throw new IllegalArgumentException("remoteRepositories: null");
}
for ( ArtifactRepository repository : remoteRepositories )
{
try
@ -351,8 +346,8 @@ public void getArtifact( Artifact artifact, List<ArtifactRepository> remoteRepos
{
logger.debug( "Unable to get resource '" + artifact.getId() + "' from repository " + repository.getId() + " (" + repository.getUrl() + ")", e );
}
}
}
// if it already exists locally we were just trying to force it - ignore the update
if ( !artifact.getFile().exists() )
{
@ -370,11 +365,15 @@ public void getArtifact( Artifact artifact, ArtifactRepository repository, Trans
throws TransferFailedException, ResourceDoesNotExistException
{
String remotePath = repository.pathOf( artifact );
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
boolean updateCheckIsRequired = updateCheckManager.isUpdateRequired( artifact, repository );
System.out.println( "update check:" + updateCheckIsRequired );
if ( !policy.isEnabled() )
{
{
logger.debug( "Skipping disabled repository " + repository.getId() );
}
else if ( repository.isBlacklisted() )
@ -383,9 +382,11 @@ else if ( repository.isBlacklisted() )
}
// If the artifact is a snapshot, we need to determine whether it's time to check this repository for an update:
// 1. If it's forced, then check
// 2. If the updateInterval has been exceeded since the last check for this artifact on this repository, then check.
else if ( artifact.isSnapshot() && ( force || updateCheckManager.isUpdateRequired( artifact, repository ) ) )
// 2. If the updateInterval has been exceeded since the last check for this artifact on this repository, then check.
else if ( artifact.isSnapshot() && ( force || updateCheckIsRequired ) )
{
System.out.println( "!!!!!!!!!!!!!!!!!!!!!");
logger.debug( "Trying repository " + repository.getId() );
try
@ -476,6 +477,8 @@ private void getRemoteFile( ArtifactRepository repository, File destination, Str
{
String protocol = repository.getProtocol();
System.out.println( wagons );
Wagon wagon;
try
@ -488,7 +491,7 @@ private void getRemoteFile( ArtifactRepository repository, File destination, Str
{
throw new TransferFailedException( "Unsupported Protocol: '" + protocol + "': " + e.getMessage(), e );
}
if ( downloadMonitor != null )
{
wagon.addTransferListener( downloadMonitor );

View File

@ -142,6 +142,8 @@ private void resolve( Artifact artifact, List<ArtifactRepository> remoteReposito
}
else if ( !artifact.isResolved() )
{
System.out.println( "looking!" );
// ----------------------------------------------------------------------
// Check for the existence of the artifact in the specified local
// ArtifactRepository. If it is present then simply return as the
@ -150,6 +152,7 @@ else if ( !artifact.isResolved() )
String localPath = localRepository.pathOf( artifact );
System.out.println( "3 " + localPath );
artifact.setFile( new File( localRepository.getBasedir(), localPath ) );
transformationManager.transformForResolve( artifact, remoteRepositories, localRepository );
@ -158,6 +161,9 @@ else if ( !artifact.isResolved() )
destination = artifact.getFile();
System.out.println( "4 " + destination );
System.out.println( "5 " + destination.exists() );
boolean resolved = false;
// There are three conditions in which we'll go after the artifact here:
@ -183,6 +189,7 @@ else if ( !artifact.isResolved() )
}
else
{
System.out.println( "trying to get artifact.");
wagonManager.getArtifact( artifact, remoteRepositories, downloadMonitor, force );
}

View File

@ -71,7 +71,7 @@ protected void tearDown()
protected ArtifactRepository badLocalRepository()
throws Exception
{
String path = "target/test-classes/repositories/" + component() + "/bad-local-repository";
String path = "target/test-repositories/" + component() + "/bad-local-repository";
File f = new File( getBasedir(), path );
@ -91,7 +91,7 @@ protected String getRepositoryLayout()
protected ArtifactRepository localRepository()
throws Exception
{
String path = "target/test-classes/repositories/" + component() + "/local-repository";
String path = "target/test-repositories/" + component() + "/local-repository";
File f = new File( getBasedir(), path );
@ -104,7 +104,7 @@ protected ArtifactRepository localRepository()
protected ArtifactRepository remoteRepository()
throws Exception
{
String path = "target/test-classes/repositories/" + component() + "/remote-repository";
String path = "target/test-repositories/" + component() + "/remote-repository";
File f = new File( getBasedir(), path );
@ -217,6 +217,8 @@ protected Artifact createRemoteArtifact( String artifactId, String version )
{
Artifact artifact = createArtifact( artifactId, version );
System.out.println( "1 " + artifact );
createArtifact( artifact, remoteRepository() );
return artifact;
@ -241,6 +243,8 @@ protected void createArtifact( Artifact artifact, ArtifactRepository repository
File artifactFile = new File( repository.getBasedir(), path );
System.out.println( "2 " + artifactFile.getParentFile() );
if ( !artifactFile.getParentFile().exists() )
{
artifactFile.getParentFile().mkdirs();
@ -268,7 +272,9 @@ protected Artifact createArtifact( String artifactId, String version, String typ
protected Artifact createArtifact( String groupId, String artifactId, String version, String type )
throws Exception
{
return artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
Artifact a = artifactFactory.createBuildArtifact( groupId, artifactId, version, type );
return a;
}
protected void deleteLocalArtifact( Artifact artifact )

View File

@ -84,9 +84,7 @@ public void testResolutionOfASingleArtifactWhereTheArtifactIsNotPresentLocallyAn
{
Artifact b = createRemoteArtifact( "b", "1.0-SNAPSHOT" );
deleteLocalArtifact( b );
artifactResolver.resolve( b, remoteRepositories(), localRepository() );
assertLocalArtifactPresent( b );
}

View File

@ -19,13 +19,9 @@ under the License.
<plexus>
<components>
<component>
<role>org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider</role>
<implementation>org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider</implementation>
</component>
<component>
<role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
<implementation>org.apache.maven.artifact.deployer.SimpleArtifactMetadataSource</implementation>
</component>
</components>
</plexus>
</plexus>

View File

@ -19,9 +19,5 @@ under the License.
<plexus>
<components>
<component>
<role>org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider</role>
<implementation>org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider</implementation>
</component>
</components>
</plexus>
</plexus>

View File

@ -44,9 +44,5 @@ under the License.
<role-hint>string</role-hint>
<implementation>org.apache.maven.artifact.manager.StringWagon</implementation>
</component>
<component>
<role>org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider</role>
<implementation>org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider</implementation>
</component>
</components>
</plexus>

View File

@ -19,9 +19,5 @@ under the License.
<plexus>
<components>
<component>
<role>org.apache.maven.artifact.repository.authentication.AuthenticationInfoProvider</role>
<implementation>org.apache.maven.artifact.repository.authentication.DummyAuthenticationInfoProvider</implementation>
</component>
</components>
</plexus>
</plexus>

View File

@ -265,8 +265,6 @@ public List<MojoDescriptor> calculateLifecyclePlan( String task, MavenSession se
for( Plugin plugin : project.getBuild().getPlugins() )
{
System.out.println( "plugin --> " + plugin );
for( PluginExecution execution : plugin.getExecutions() )
{
// if the phase is specified then I don't have to go fetch the plugin yet and pull it down

View File

@ -72,7 +72,6 @@
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.component.discovery.ComponentDiscoverer;
import org.codehaus.plexus.component.discovery.ComponentDiscovererManager;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
@ -132,7 +131,6 @@ public class DefaultPluginManager
public DefaultPluginManager()
{
System.out.println( "hello!!!!");
pluginDescriptors = new HashMap<String,PluginDescriptor>();
}
@ -150,8 +148,6 @@ public PluginDescriptor loadPlugin( Plugin plugin, MavenProject project, MavenSe
{
PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin );
System.out.println( "XXX plugin: " + plugin );
// There are cases where plugins are discovered but not actually populated. These are edge cases where you are working in the IDE on
// Maven itself so this speaks to a problem we have with the system not starting entirely clean.
if ( pluginDescriptor != null && pluginDescriptor.getClassRealm() != null )
@ -216,8 +212,6 @@ protected PluginDescriptor addPlugin( Plugin plugin, MavenProject project, Maven
resolutionErrorHandler.throwErrors( request, result );
ClassRealm pluginRealm = container.createChildRealm( pluginKey( plugin ) );
System.out.println( "plugin: " + pluginArtifact );
Set<Artifact> pluginArtifacts = getPluginArtifacts( pluginArtifact, plugin, project, session.getLocalRepository() );
@ -589,13 +583,17 @@ private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject
return mojo;
}
catch ( PlexusConfigurationException e )
{
throw new PluginConfigurationException( pluginDescriptor, "Error checking parameters: " + e.getMessage() );
}
finally
{
Thread.currentThread().setContextClassLoader( oldClassLoader );
}
}
private void checkDeprecatedParameters( MojoDescriptor mojoDescriptor, PlexusConfiguration extractedMojoConfiguration )
private void checkDeprecatedParameters( MojoDescriptor mojoDescriptor, PlexusConfiguration extractedMojoConfiguration ) throws PlexusConfigurationException
{
if ( ( extractedMojoConfiguration == null ) || ( extractedMojoConfiguration.getChildCount() < 1 ) )
{
@ -1232,8 +1230,6 @@ public ComponentSetDescriptor createComponentDescriptors( Reader componentDescri
public List<ComponentSetDescriptor> findComponents( Context context, ClassRealm realm )
throws PlexusConfigurationException
{
System.out.println( "realm: " + realm );
List<ComponentSetDescriptor> componentSetDescriptors = new ArrayList<ComponentSetDescriptor>();
Enumeration<URL> resources;
@ -1282,13 +1278,8 @@ public List<ComponentSetDescriptor> findComponents( Context context, ClassRealm
cd.setRealm( realm );
}
}
componentSetDescriptors.add( componentSetDescriptor );
// Fire the event
ComponentDiscoveryEvent event = new ComponentDiscoveryEvent( componentSetDescriptor );
componentDiscovererManager.fireComponentDiscoveryEvent( event );
}
catch ( IOException ex )
{
@ -1302,11 +1293,6 @@ public List<ComponentSetDescriptor> findComponents( Context context, ClassRealm
return componentSetDescriptors;
}
public void setManager( ComponentDiscovererManager manager )
{
this.componentDiscovererManager = manager;
}
// ----------------------------------------------------------------------
// Component Discovery Listener
@ -1315,9 +1301,7 @@ public void setManager( ComponentDiscovererManager manager )
private Set pluginsInProcess = new HashSet();
private Map pluginIdsByPrefix = new HashMap();
private ComponentDiscovererManager componentDiscovererManager;
public void componentDiscovered( ComponentDiscoveryEvent event )
{
ComponentSetDescriptor componentSetDescriptor = event.getComponentSetDescriptor();

View File

@ -20,11 +20,14 @@
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.discovery.ComponentDiscoverer;
import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener;
/**
* @author Jason van Zyl
*/
public interface PluginManager
extends ComponentDiscoverer, ComponentDiscoveryListener
{
// - find the plugin [extension point: any client may wish to do whatever they choose]
// - load the plugin into a classloader [extension point: we want to take them from a repository, some may take from disk or whatever]

View File

@ -57,7 +57,7 @@ under the License.
<doxiaVersion>1.0-alpha-9</doxiaVersion>
<easyMockVersion>1.2_Java1.3</easyMockVersion>
<junitVersion>3.8.1</junitVersion>
<plexusVersion>1.0-beta-4-SNAPSHOT</plexusVersion>
<plexusVersion>1.0-beta-3.0.7-SNAPSHOT</plexusVersion>
<plexusInteractivityVersion>1.0-alpha-6</plexusInteractivityVersion>
<plexusInterpolationVersion>1.1</plexusInterpolationVersion>
<plexusPluginManagerVersion>1.0-alpha-1</plexusPluginManagerVersion>