o make a very simple utility for creating our artifact filter so that it can be shared by the

plugin manager and the extension manger. now used in the extension manager to block out
  deps that are already present in the maven classloading system. so that something like
  the external provider can be listed in an extension and will be dealt with: this was
  causing a loader constraint violation.



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@368218 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2006-01-12 02:00:16 +00:00
parent 2dcba6b9c3
commit 69aadf79da
4 changed files with 119 additions and 53 deletions

View File

@ -32,6 +32,7 @@ import java.util.Set;
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka </a>
* @version $Id$
* @todo possibly fix the signatures, it's unfortunate that in some methods the local repo is listed first and second in others.
*/
public interface ArtifactResolver
{
@ -40,33 +41,53 @@ public interface ArtifactResolver
void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories,
ArtifactRepository localRepository, ArtifactMetadataSource source )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories,
ArtifactRepository localRepository, ArtifactMetadataSource source,
List listeners )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
ArtifactRepository localRepository, List remoteRepositories,
ArtifactResolutionResult resolveTransitively( Set artifacts,
Artifact originatingArtifact,
List remoteRepositories,
ArtifactRepository localRepository,
ArtifactMetadataSource source )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
ArtifactRepository localRepository, List remoteRepositories,
ArtifactResolutionResult resolveTransitively( Set artifacts,
Artifact originatingArtifact,
List remoteRepositories,
ArtifactRepository localRepository,
ArtifactMetadataSource source,
List listeners )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts,
Artifact originatingArtifact,
ArtifactRepository localRepository,
List remoteRepositories,
ArtifactMetadataSource source,
ArtifactFilter filter )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts,
Artifact originatingArtifact,
Map managedVersions,
ArtifactRepository localRepository,
List remoteRepositories,
ArtifactMetadataSource source )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts,
Artifact originatingArtifact,
Map managedVersions,
ArtifactRepository localRepository,
List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
ArtifactResolutionResult resolveTransitively( Set artifacts,
Artifact originatingArtifact,
Map managedVersions,
ArtifactRepository localRepository,
List remoteRepositories,
ArtifactMetadataSource source,
ArtifactFilter filter,
List listeners )
throws ArtifactResolutionException, ArtifactNotFoundException;
void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )

View File

@ -0,0 +1,67 @@
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.maven;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
import java.util.Set;
import java.util.HashSet;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id:$
* @todo this should probably be a component with some dynamic control of filtering
*/
public class MavenArtifactFilterManager
{
public static ArtifactFilter createStandardFilter()
{
// TODO: configure this from bootstrap or scan lib
Set artifacts = new HashSet();
artifacts.add( "classworlds" );
artifacts.add( "commons-cli" );
artifacts.add( "doxia-sink-api" );
artifacts.add( "jsch" );
artifacts.add( "maven-artifact" );
artifacts.add( "maven-artifact-manager" );
artifacts.add( "maven-core" );
artifacts.add( "maven-error-diagnoser" );
artifacts.add( "maven-model" );
artifacts.add( "maven-monitor" );
artifacts.add( "maven-plugin-api" );
artifacts.add( "maven-plugin-descriptor" );
artifacts.add( "maven-plugin-parameter-documenter" );
artifacts.add( "maven-plugin-registry" );
artifacts.add( "maven-profile" );
artifacts.add( "maven-project" );
artifacts.add( "maven-reporting-api" );
artifacts.add( "maven-repository-metadata" );
artifacts.add( "maven-settings" );
artifacts.add( "plexus-container-default" );
artifacts.add( "plexus-interactivity-api" );
artifacts.add( "plexus-utils" );
artifacts.add( "wagon-provider-api" );
artifacts.add( "wagon-file" );
artifacts.add( "wagon-http-lightweight" );
artifacts.add( "wagon-ssh" );
artifacts.add( "wagon-ssh-external" );
return new ExclusionSetFilter( artifacts );
}
}

View File

@ -24,8 +24,10 @@ import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.model.Extension;
import org.apache.maven.project.MavenProject;
import org.apache.maven.MavenArtifactFilterManager;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
@ -40,6 +42,7 @@ import java.util.Iterator;
* Used to locate extensions.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @author Jason van Zyl
* @version $Id$
*/
public class DefaultExtensionManager
@ -51,6 +54,8 @@ public class DefaultExtensionManager
private PlexusContainer container;
private ArtifactFilter artifactFilter = MavenArtifactFilterManager.createStandardFilter();
public void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository )
throws ArtifactResolutionException, PlexusContainerException, ArtifactNotFoundException
{
@ -62,9 +67,10 @@ public class DefaultExtensionManager
{
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( artifact ),
project.getArtifact(),
project.getRemoteArtifactRepositories(),
localRepository,
artifactMetadataSource );
project.getRemoteArtifactRepositories(),
artifactMetadataSource,
artifactFilter );
for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
{
Artifact a = (Artifact) i.next();

View File

@ -55,6 +55,7 @@ import org.apache.maven.project.artifact.MavenMetadataSource;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.reporting.MavenReport;
import org.apache.maven.settings.Settings;
import org.apache.maven.MavenArtifactFilterManager;
import org.codehaus.plexus.PlexusConstants;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.PlexusContainerException;
@ -1092,36 +1093,7 @@ public class DefaultPluginManager
public void initialize()
{
// TODO: configure this from bootstrap or scan lib
Set artifacts = new HashSet();
artifacts.add( "classworlds" );
artifacts.add( "commons-cli" );
artifacts.add( "doxia-sink-api" );
artifacts.add( "jsch" );
artifacts.add( "maven-artifact" );
artifacts.add( "maven-artifact-manager" );
artifacts.add( "maven-core" );
artifacts.add( "maven-error-diagnoser" );
artifacts.add( "maven-model" );
artifacts.add( "maven-monitor" );
artifacts.add( "maven-plugin-api" );
artifacts.add( "maven-plugin-descriptor" );
artifacts.add( "maven-plugin-parameter-documenter" );
artifacts.add( "maven-plugin-registry" );
artifacts.add( "maven-profile" );
artifacts.add( "maven-project" );
artifacts.add( "maven-reporting-api" );
artifacts.add( "maven-repository-metadata" );
artifacts.add( "maven-settings" );
artifacts.add( "plexus-container-default" );
artifacts.add( "plexus-interactivity-api" );
artifacts.add( "plexus-utils" );
artifacts.add( "wagon-provider-api" );
artifacts.add( "wagon-file" );
artifacts.add( "wagon-http-lightweight" );
artifacts.add( "wagon-ssh" );
artifacts.add( "wagon-ssh-external" );
artifactFilter = new ExclusionSetFilter( artifacts );
artifactFilter = MavenArtifactFilterManager.createStandardFilter();
}
// ----------------------------------------------------------------------