diff --git a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java index 437c3e7055..0bf1dd45e1 100644 --- a/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java +++ b/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/ArtifactResolver.java @@ -32,6 +32,7 @@ import java.util.Set; * * @author Michal Maczka * @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 ) diff --git a/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java b/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java new file mode 100644 index 0000000000..f328ffb28f --- /dev/null +++ b/maven-core/src/main/java/org/apache/maven/MavenArtifactFilterManager.java @@ -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 Jason van Zyl + * @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 ); + } +} diff --git a/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java b/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java index b40b9f207a..22ab61a2a0 100644 --- a/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java +++ b/maven-core/src/main/java/org/apache/maven/extension/DefaultExtensionManager.java @@ -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 Brett Porter + * @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(); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java index 31942f458b..5dde3d1a76 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java @@ -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(); } // ----------------------------------------------------------------------