]> source.dussan.org Git - archiva.git/commitdiff
remove dependency on maven tree component
authorOlivier Lamy <olamy@apache.org>
Sat, 4 Aug 2012 21:28:22 +0000 (21:28 +0000)
committerOlivier Lamy <olamy@apache.org>
Sat, 4 Aug 2012 21:28:22 +0000 (21:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1369472 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/tags/DependencyTree.java
archiva-modules/plugins/maven2-repository/pom.xml
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java [deleted file]
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilder.java
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderException.java [new file with mode: 0644]
archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/Maven3DependencyTreeBuilder.java
archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java [deleted file]
pom.xml

index ff075ee2e212e2a63e2ead9ddb07c394a981ba6c..18739140131a1bd4cc751dfff149cce05a62f70a 100644 (file)
@@ -21,7 +21,6 @@ package org.apache.archiva.rest.services;
 import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.common.utils.VersionComparator;
 import org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder;
-import org.apache.archiva.dependency.tree.maven2.Maven3DependencyTreeBuilder;
 import org.apache.archiva.maven2.model.Artifact;
 import org.apache.archiva.maven2.model.TreeEntry;
 import org.apache.archiva.metadata.generic.GenericMetadataFacet;
@@ -90,9 +89,6 @@ public class DefaultBrowseService
     @Inject
     private DependencyTreeBuilder dependencyTreeBuilder;
 
-    @Inject
-    private Maven3DependencyTreeBuilder maven3DependencyTreeBuilder;
-
     @Inject
     private RepositoryContentFactory repositoryContentFactory;
 
@@ -429,7 +425,7 @@ public class DefaultBrowseService
         try
         {
 
-            return maven3DependencyTreeBuilder.buildDependencyTree( selectedRepos, groupId, artifactId, version );
+            return dependencyTreeBuilder.buildDependencyTree( selectedRepos, groupId, artifactId, version );
 
         }
         catch ( Exception e )
index cab7afee68c61149198a66bfd8c82b8f68625b08..7ec3cf3b59b09298f533e7b37b0831cdc15cd494 100644 (file)
@@ -21,12 +21,11 @@ package org.apache.archiva.web.tags;
 
 import com.opensymphony.xwork2.ActionContext;
 import org.apache.archiva.common.ArchivaException;
-import org.apache.archiva.dependency.tree.maven2.Maven3DependencyTreeBuilder;
+import org.apache.archiva.dependency.tree.maven2.DependencyTreeBuilder;
 import org.apache.archiva.model.Keys;
 import org.apache.archiva.security.ArchivaXworkUser;
 import org.apache.archiva.security.UserRepositories;
 import org.apache.commons.lang.StringUtils;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonatype.aether.artifact.Artifact;
@@ -48,7 +47,7 @@ public class DependencyTree
 
 
     @Inject
-    private Maven3DependencyTreeBuilder dependencyTreeBuilder;
+    private DependencyTreeBuilder dependencyTreeBuilder;
 
     @Inject
     private UserRepositories userRepositories;
index ea8aee18898cd880fec9010db1890bc95f56ad70..bf1cafbb38de59f67790ec1be05e829204df4e2b 100644 (file)
       <artifactId>aether-connector-file</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>org.apache.maven.shared</groupId>
-      <artifactId>maven-dependency-tree</artifactId>
-      <exclusions>
-        <exclusion>
-          <groupId>org.apache.maven</groupId>
-          <artifactId>maven-project</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
     <dependency>
       <groupId>org.apache.archiva</groupId>
       <artifactId>archiva-configuration</artifactId>
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DefaultDependencyTreeBuilder.java
deleted file mode 100644 (file)
index 6067dd7..0000000
+++ /dev/null
@@ -1,585 +0,0 @@
-package org.apache.archiva.dependency.tree.maven2;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-
-import org.apache.archiva.admin.model.RepositoryAdminException;
-import org.apache.archiva.admin.model.beans.ManagedRepository;
-import org.apache.archiva.admin.model.beans.NetworkProxy;
-import org.apache.archiva.admin.model.beans.ProxyConnector;
-import org.apache.archiva.admin.model.beans.RemoteRepository;
-import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
-import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin;
-import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin;
-import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
-import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
-import org.apache.archiva.common.utils.Slf4JPlexusLogger;
-import org.apache.archiva.metadata.repository.MetadataResolutionException;
-import org.apache.archiva.metadata.repository.MetadataResolver;
-import org.apache.archiva.metadata.repository.RepositorySession;
-import org.apache.archiva.metadata.repository.RepositorySessionFactory;
-import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator;
-import org.apache.archiva.metadata.repository.storage.maven2.RepositoryModelResolver;
-import org.apache.archiva.proxy.common.WagonFactory;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.metadata.ResolutionGroup;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
-import org.apache.maven.artifact.versioning.ManagedVersionMap;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.DependencyManagement;
-import org.apache.maven.model.Exclusion;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.building.DefaultModelBuilderFactory;
-import org.apache.maven.model.building.DefaultModelBuildingRequest;
-import org.apache.maven.model.building.ModelBuilder;
-import org.apache.maven.model.building.ModelBuildingException;
-import org.apache.maven.model.building.ModelBuildingRequest;
-import org.apache.maven.model.resolution.UnresolvableModelException;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.maven.shared.dependency.tree.DependencyTreeResolutionListener;
-import org.apache.maven.shared.dependency.tree.filter.AncestorOrSelfDependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.filter.DependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.filter.StateDependencyNodeFilter;
-import org.apache.maven.shared.dependency.tree.traversal.BuildingDependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.CollectingDependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.apache.maven.shared.dependency.tree.traversal.FilteringDependencyNodeVisitor;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.PostConstruct;
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Default implementation of <code>DependencyTreeBuilder</code>. Customized wrapper for maven-dependency-tree to use
- * maven-model-builder instead of maven-project. Note that the role must differ to avoid conflicting with the
- * maven-shared implementation.
- */
-@Service( "dependencyTreeBuilder#maven2" )
-public class DefaultDependencyTreeBuilder
-    implements DependencyTreeBuilder
-{
-
-    private Logger log = LoggerFactory.getLogger( getClass() );
-
-    /**
-     *
-     */
-    private ArtifactFactory factory;
-
-    /**
-     *
-     */
-    private ArtifactCollector collector;
-
-    /**
-     *
-     */
-    private ModelBuilder builder;
-
-    /**
-     * TODO: can have other types, and this might eventually come through from the main request
-     */
-    @Inject
-    private RepositorySessionFactory repositorySessionFactory;
-
-    /**
-     *
-     */
-    @Inject
-    @Named( value = "repositoryPathTranslator#maven2" )
-    private RepositoryPathTranslator pathTranslator;
-
-    @Inject
-    private ProxyConnectorAdmin proxyConnectorAdmin;
-
-    @Inject
-    private NetworkProxyAdmin networkProxyAdmin;
-
-    @Inject
-    private RemoteRepositoryAdmin remoteRepositoryAdmin;
-
-    @Inject
-    private ManagedRepositoryAdmin managedRepositoryAdmin;
-
-    @Inject
-    private PlexusSisuBridge plexusSisuBridge;
-
-    @Inject
-    private WagonFactory wagonFactory;
-
-    @PostConstruct
-    public void initialize()
-        throws PlexusSisuBridgeException
-    {
-        factory = plexusSisuBridge.lookup( ArtifactFactory.class, "default" );
-        collector = plexusSisuBridge.lookup( ArtifactCollector.class, "default" );
-
-        DefaultModelBuilderFactory defaultModelBuilderFactory = new DefaultModelBuilderFactory();
-        builder = defaultModelBuilderFactory.newInstance();
-    }
-
-    public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
-                                     DependencyNodeVisitor nodeVisitor )
-        throws DependencyTreeBuilderException
-    {
-        DependencyTreeResolutionListener listener =
-            new DependencyTreeResolutionListener( new Slf4JPlexusLogger( getClass() ) );
-
-        Artifact projectArtifact = factory.createProjectArtifact( groupId, artifactId, version );
-        ManagedRepository repository = null;
-        try
-        {
-            repository = findArtifactInRepositories( repositoryIds, projectArtifact );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
-        }
-
-        if ( repository == null )
-        {
-            // metadata could not be resolved
-            return;
-        }
-
-        try
-        {
-            // MRM-1411
-            // TODO: this is a workaround for a lack of proxy capability in the resolvers - replace when it can all be
-            //       handled there. It doesn't cache anything locally!
-            List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
-            Map<String, NetworkProxy> networkProxies = new HashMap<String, NetworkProxy>();
-
-            Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
-            List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( repository.getId() );
-            if ( proxyConnectors != null )
-            {
-                for ( ProxyConnector proxyConnector : proxyConnectors )
-                {
-                    remoteRepositories.add(
-                        remoteRepositoryAdmin.getRemoteRepository( proxyConnector.getTargetRepoId() ) );
-
-                    NetworkProxy networkProxyConfig = networkProxyAdmin.getNetworkProxy( proxyConnector.getProxyId() );
-
-                    if ( networkProxyConfig != null )
-                    {
-                        // key/value: remote repo ID/proxy info
-                        networkProxies.put( proxyConnector.getTargetRepoId(), networkProxyConfig );
-                    }
-                }
-            }
-
-            Model model = buildProject(
-                new RepositoryModelResolver( repository, pathTranslator, wagonFactory, remoteRepositories, networkProxies,
-                                             repository ), groupId, artifactId, version );
-
-            Map managedVersions = createManagedVersionMap( model );
-
-            Set<Artifact> dependencyArtifacts = createArtifacts( model, null );
-
-            RepositorySession repositorySession = repositorySessionFactory.createSession();
-            try
-            {
-                ArtifactMetadataSource metadataSource =
-                    new MetadataArtifactMetadataSource( repositoryIds, repositorySession );
-
-                // Note that we don't permit going to external repositories. We don't need to pass in a local and remote
-                // since our metadata source has control over them
-                collector.collect( dependencyArtifacts, projectArtifact, managedVersions, null, null, metadataSource,
-                                   null, Collections.singletonList( listener ) );
-
-                //collector.collect( dependencyArtifacts, projectArtifact, null, Collections.<ArtifactRepository>emptyList(),
-                //                   metadataSource, null,  Collections.singletonList( (ResolutionListener) listener ) );
-
-                /*
-                Set<Artifact> artifacts, Artifact originatingArtifact,
-                                      ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
-                                      ArtifactMetadataSource source, ArtifactFilter filter,
-                                      List< ResolutionListener > listeners
-                */
-            }
-            finally
-            {
-                repositorySession.close();
-            }
-
-            DependencyNode rootNode = listener.getRootNode();
-
-            // TODO: remove the need for this when the serializer can calculate last nodes from visitor calls only
-            DependencyNodeVisitor visitor = new BuildingDependencyNodeVisitor( nodeVisitor );
-
-            CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
-            DependencyNodeVisitor firstPassVisitor =
-                new FilteringDependencyNodeVisitor( collectingVisitor, StateDependencyNodeFilter.INCLUDED );
-            rootNode.accept( firstPassVisitor );
-
-            DependencyNodeFilter secondPassFilter =
-                new AncestorOrSelfDependencyNodeFilter( collectingVisitor.getNodes() );
-            visitor = new FilteringDependencyNodeVisitor( visitor, secondPassFilter );
-
-            rootNode.accept( visitor );
-        }
-        catch ( ArtifactResolutionException e )
-        {
-            throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
-        }
-        catch ( InvalidVersionSpecificationException e )
-        {
-            throw new DependencyTreeBuilderException( "Invalid dependency version for artifact " + projectArtifact );
-        }
-        catch ( ModelBuildingException e )
-        {
-            throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
-        }
-        catch ( UnresolvableModelException e )
-        {
-            throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
-        }
-        catch ( RepositoryAdminException e )
-        {
-            throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
-        }
-    }
-
-    private ManagedRepository findArtifactInRepositories( List<String> repositoryIds, Artifact projectArtifact )
-        throws RepositoryAdminException
-    {
-        for ( String repoId : repositoryIds )
-        {
-            ManagedRepository managedRepository = managedRepositoryAdmin.getManagedRepository( repoId );
-
-            File repoDir = new File( managedRepository.getLocation() );
-            File file = pathTranslator.toFile( repoDir, projectArtifact.getGroupId(), projectArtifact.getArtifactId(),
-                                               projectArtifact.getBaseVersion(),
-                                               projectArtifact.getArtifactId() + "-" + projectArtifact.getVersion()
-                                                   + ".pom" );
-
-            if ( file.exists() )
-            {
-                return managedRepository;
-            }
-        }
-        return null;
-    }
-
-    private Model buildProject( RepositoryModelResolver modelResolver, String groupId, String artifactId,
-                                String version )
-        throws ModelBuildingException, UnresolvableModelException
-    {
-        ModelBuildingRequest req = new DefaultModelBuildingRequest();
-        req.setProcessPlugins( false );
-        req.setModelSource( modelResolver.resolveModel( groupId, artifactId, version ) );
-        req.setModelResolver( modelResolver );
-        req.setValidationLevel( ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL );
-        //MRM-1607. olamy this will resolve jdk profiles on the current running archiva jvm
-        req.setSystemProperties( System.getProperties() );
-
-        return builder.build( req ).getEffectiveModel();
-    }
-
-    // from maven-project to avoid the dependency on it
-    private Set<Artifact> createArtifacts( Model model, ArtifactFilter dependencyFilter )
-        throws InvalidVersionSpecificationException
-    {
-        Collection<Dependency> dependencies = model.getDependencies();
-        Set<Artifact> projectArtifacts = new LinkedHashSet<Artifact>( dependencies.size() );
-
-        for ( Dependency dependency : dependencies )
-        {
-            String scope = dependency.getScope();
-
-            if ( StringUtils.isEmpty( scope ) )
-            {
-                scope = Artifact.SCOPE_COMPILE;
-
-                dependency.setScope( scope );
-            }
-
-            VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );
-            Artifact artifact =
-                factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), versionRange,
-                                                  dependency.getType(), dependency.getClassifier(), scope, null,
-                                                  dependency.isOptional() );
-
-            if ( Artifact.SCOPE_SYSTEM.equals( scope ) )
-            {
-                artifact.setFile( new File( dependency.getSystemPath() ) );
-            }
-
-            ArtifactFilter artifactFilter = dependencyFilter;
-
-            // MNG-3769: It would be nice to be able to process relocations here,
-            // so we could have this filtering step apply to post-relocated dependencies.
-            // HOWEVER, this would require a much more invasive POM resolution process
-            // in order to look for relocations, which would make the early steps in
-            // a Maven build way too heavy.
-            if ( artifact != null && ( artifactFilter == null || artifactFilter.include( artifact ) ) )
-            {
-                if ( dependency.getExclusions() != null && !dependency.getExclusions().isEmpty() )
-                {
-                    List<String> exclusions = new ArrayList<String>();
-                    for ( Object o : dependency.getExclusions() )
-                    {
-                        Exclusion e = (Exclusion) o;
-                        exclusions.add( e.getGroupId() + ":" + e.getArtifactId() );
-                    }
-
-                    ArtifactFilter newFilter = new ExcludesArtifactFilter( exclusions );
-
-                    if ( artifactFilter != null )
-                    {
-                        AndArtifactFilter filter = new AndArtifactFilter();
-                        filter.add( artifactFilter );
-                        filter.add( newFilter );
-                        artifactFilter = filter;
-                    }
-                    else
-                    {
-                        artifactFilter = newFilter;
-                    }
-                }
-
-                artifact.setDependencyFilter( artifactFilter );
-
-                projectArtifacts.add( artifact );
-            }
-        }
-
-        return projectArtifacts;
-
-    }
-
-    // from maven-project to avoid the dependency on it
-
-    private Map createManagedVersionMap( Model model )
-        throws InvalidVersionSpecificationException
-    {
-        DependencyManagement dependencyManagement = model.getDependencyManagement();
-
-        Map<String, Artifact> map = null;
-        List<Dependency> deps;
-        if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) && (
-            deps.size() > 0 ) )
-        {
-            map = new ManagedVersionMap( map );
-
-            for ( Dependency dependency : dependencyManagement.getDependencies() )
-            {
-
-                VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() );
-
-                Artifact artifact =
-                    factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), versionRange,
-                                                      dependency.getType(), dependency.getClassifier(),
-                                                      dependency.getScope(), dependency.isOptional() );
-
-                log.debug( "artifact {}", artifact );
-
-                // If the dependencyManagement section listed exclusions,
-                // add them to the managed artifacts here so that transitive
-                // dependencies will be excluded if necessary.
-                if ( ( null != dependency.getExclusions() ) && !dependency.getExclusions().isEmpty() )
-                {
-                    List<String> exclusions = new ArrayList<String>();
-
-                    for ( Exclusion exclusion : dependency.getExclusions() )
-                    {
-                        exclusions.add( exclusion.getGroupId() + ":" + exclusion.getArtifactId() );
-                    }
-                    ExcludesArtifactFilter eaf = new ExcludesArtifactFilter( exclusions );
-                    artifact.setDependencyFilter( eaf );
-                }
-                else
-                {
-                    artifact.setDependencyFilter( null );
-                }
-                map.put( dependency.getManagementKey(), artifact );
-            }
-        }
-        else
-        {
-            map = Collections.emptyMap();
-        }
-
-        return map;
-    }
-
-    private class MetadataArtifactMetadataSource
-        implements ArtifactMetadataSource
-    {
-        private final List<String> repositoryIds;
-
-        private final RepositorySession session;
-
-        private final MetadataResolver resolver;
-
-        public MetadataArtifactMetadataSource( List<String> repositoryIds, RepositorySession session )
-        {
-            this.repositoryIds = repositoryIds;
-            this.session = session;
-            resolver = this.session.getResolver();
-        }
-
-        // modified version from MavenMetadataSource to work with the simpler environment
-        public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository,
-                                         List remoteRepositories )
-            throws ArtifactMetadataRetrievalException
-        {
-            // TODO: we removed relocation support here. This is something that might need to be generically handled
-            //       throughout this module
-
-            Artifact pomArtifact =
-                factory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(),
-                                               artifact.getScope() );
-
-            ManagedRepository repository = null;
-            try
-            {
-                repository = findArtifactInRepositories( repositoryIds, pomArtifact );
-            }
-            catch ( RepositoryAdminException e )
-            {
-                throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
-            }
-            Model project = null;
-            if ( !Artifact.SCOPE_SYSTEM.equals( artifact.getScope() ) && repository != null )
-            {
-
-                try
-                {
-
-                    File basedir = new File( repository.getLocation() );
-                    project =
-                        buildProject( new RepositoryModelResolver( basedir, pathTranslator ), artifact.getGroupId(),
-                                      artifact.getArtifactId(), artifact.getVersion() );
-                }
-                catch ( ModelBuildingException e )
-                {
-                    throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
-                }
-                catch ( UnresolvableModelException e )
-                {
-                    throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
-                }
-
-            }
-
-            ResolutionGroup result;
-
-            if ( project == null )
-            {
-                // TODO: we could record this so that it is displayed in the dependency tree as (...) or similar
-
-                // if the project is null, we encountered an invalid model (read: m1 POM)
-                // we'll just return an empty resolution group.
-                // or used the inherited scope (should that be passed to the buildFromRepository method above?)
-                result = new ResolutionGroup( pomArtifact, Collections.<Artifact>emptySet(),
-                                              Collections.<ArtifactRepository>emptyList() );
-            }
-            else
-            {
-                Set<Artifact> artifacts = Collections.emptySet();
-                if ( !artifact.getArtifactHandler().isIncludesDependencies() )
-                {
-                    try
-                    {
-                        artifacts = createArtifacts( project, artifact.getDependencyFilter() );
-                    }
-                    catch ( InvalidVersionSpecificationException e )
-                    {
-                        throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
-                    }
-                }
-
-                result = new ResolutionGroup( pomArtifact, artifacts, Collections.<ArtifactRepository>emptyList() );
-            }
-
-            return result;
-        }
-
-        public List retrieveAvailableVersions( Artifact artifact, ArtifactRepository localRepository,
-                                               List remoteRepositories )
-            throws ArtifactMetadataRetrievalException
-        {
-            Set<ArtifactVersion> versions = new HashSet<ArtifactVersion>();
-            for ( String repoId : repositoryIds )
-            {
-                Collection<String> projectVersions;
-                try
-                {
-                    projectVersions = resolver.resolveProjectVersions( session, repoId, artifact.getGroupId(),
-                                                                       artifact.getArtifactId() );
-                }
-                catch ( MetadataResolutionException e )
-                {
-                    throw new ArtifactMetadataRetrievalException( e.getMessage(), e, artifact );
-                }
-                for ( String version : projectVersions )
-                {
-                    versions.add( new DefaultArtifactVersion( version ) );
-                }
-            }
-
-            return new ArrayList<ArtifactVersion>( versions );
-        }
-
-
-        public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact,
-                                                                                        ArtifactRepository artifactRepository,
-                                                                                        ArtifactRepository artifactRepository1 )
-            throws ArtifactMetadataRetrievalException
-        {
-            // TODO
-            return null;
-        }
-    }
-
-    public ArtifactFactory getFactory()
-    {
-        return factory;
-    }
-}
\ No newline at end of file
index 73f843c650965eb20225ec1e050cb349b473baf4..1c6ad53298dd3b5dd757a4656e332dfd2dd76ef9 100644 (file)
@@ -1,5 +1,4 @@
 package org.apache.archiva.dependency.tree.maven2;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -9,7 +8,7 @@ package org.apache.archiva.dependency.tree.maven2;
  * "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
+ *   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
@@ -19,28 +18,21 @@ package org.apache.archiva.dependency.tree.maven2;
  * under the License.
  */
 
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
+import org.apache.archiva.maven2.model.TreeEntry;
+import org.sonatype.aether.graph.DependencyVisitor;
 
 import java.util.List;
 
 /**
- * Builds a tree of dependencies for a given Maven project. Customized wrapper for maven-dependency-tree to use
- * maven-model-builder instead of maven-project.
+ * @author Olivier Lamy
  */
 public interface DependencyTreeBuilder
 {
-    /**
-     * Builds a tree of dependencies for the specified Maven project.
-     *
-     * @param repositoryIds the list of repositories to search for metadata
-     * @param groupId       the project groupId to build the tree for
-     * @param artifactId    the project artifactId to build the tree for
-     * @param version       the project version to build the tree for
-     * @param nodeVisitor   visitor to apply to all nodes discovered
-     * @throws DependencyTreeBuilderException if the dependency tree cannot be resolved
-     */
     void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
-                              DependencyNodeVisitor nodeVisitor )
-        throws DependencyTreeBuilderException;
+                              DependencyVisitor dependencyVisitor )
+        throws Exception;
+
+    List<TreeEntry> buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version )
+        throws Exception;
 }
+
diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderException.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderException.java
new file mode 100644 (file)
index 0000000..ea71d78
--- /dev/null
@@ -0,0 +1,32 @@
+package org.apache.archiva.dependency.tree.maven2;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+public class DependencyTreeBuilderException
+    extends Exception
+{
+    public DependencyTreeBuilderException( String message, Throwable t )
+    {
+        super( message, t );
+    }
+}
index eec25bf375437d8fcf4ae6d456b5d286079ef2e7..d632c4250654f68fb3c0151c2e2e96521323d0e9 100644 (file)
@@ -78,6 +78,7 @@ import java.util.Map;
  */
 @Service( "dependencyTreeBuilder#maven3" )
 public class Maven3DependencyTreeBuilder
+    implements DependencyTreeBuilder
 {
     private Logger log = LoggerFactory.getLogger( getClass() );
 
@@ -123,7 +124,7 @@ public class Maven3DependencyTreeBuilder
 
     public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
                                      DependencyVisitor dependencyVisitor )
-        throws Exception
+        throws DependencyTreeBuilderException
     {
         Artifact projectArtifact = factory.createProjectArtifact( groupId, artifactId, version );
         ManagedRepository repository = null;
@@ -134,7 +135,7 @@ public class Maven3DependencyTreeBuilder
         catch ( RepositoryAdminException e )
         {
             // FIXME better exception
-            throw new Exception( "Cannot build project dependency tree " + e.getMessage(), e );
+            throw new DependencyTreeBuilderException( "Cannot build project dependency tree " + e.getMessage(), e );
         }
 
         if ( repository == null )
@@ -143,29 +144,36 @@ public class Maven3DependencyTreeBuilder
             return;
         }
 
-        // MRM-1411
-        // TODO: this is a workaround for a lack of proxy capability in the resolvers - replace when it can all be
-        //       handled there. It doesn't cache anything locally!
-        List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
-        Map<String, NetworkProxy> networkProxies = new HashMap<String, NetworkProxy>();
-
-        Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
-        List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( repository.getId() );
-        if ( proxyConnectors != null )
+        try
         {
-            for ( ProxyConnector proxyConnector : proxyConnectors )
+            // MRM-1411
+            // TODO: this is a workaround for a lack of proxy capability in the resolvers - replace when it can all be
+            //       handled there. It doesn't cache anything locally!
+            List<RemoteRepository> remoteRepositories = new ArrayList<RemoteRepository>();
+            Map<String, NetworkProxy> networkProxies = new HashMap<String, NetworkProxy>();
+
+            Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
+            List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( repository.getId() );
+            if ( proxyConnectors != null )
             {
-                remoteRepositories.add( remoteRepositoryAdmin.getRemoteRepository( proxyConnector.getTargetRepoId() ) );
+                for ( ProxyConnector proxyConnector : proxyConnectors )
+                {
+                    remoteRepositories.add( remoteRepositoryAdmin.getRemoteRepository( proxyConnector.getTargetRepoId() ) );
 
-                NetworkProxy networkProxyConfig = networkProxyAdmin.getNetworkProxy( proxyConnector.getProxyId() );
+                    NetworkProxy networkProxyConfig = networkProxyAdmin.getNetworkProxy( proxyConnector.getProxyId() );
 
-                if ( networkProxyConfig != null )
-                {
-                    // key/value: remote repo ID/proxy info
-                    networkProxies.put( proxyConnector.getTargetRepoId(), networkProxyConfig );
+                    if ( networkProxyConfig != null )
+                    {
+                        // key/value: remote repo ID/proxy info
+                        networkProxies.put( proxyConnector.getTargetRepoId(), networkProxyConfig );
+                    }
                 }
             }
         }
+        catch ( RepositoryAdminException e )
+        {
+            throw new DependencyTreeBuilderException( e.getMessage(), e );
+        }
 
         // FIXME take care of relative path
         resolve( repository.getLocation(), groupId, artifactId, version, dependencyVisitor );
@@ -174,7 +182,7 @@ public class Maven3DependencyTreeBuilder
 
     public List<TreeEntry> buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId,
                                                 String version )
-        throws Exception
+        throws DependencyTreeBuilderException
     {
 
         List<TreeEntry> treeEntries = new ArrayList<TreeEntry>();
diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/dependency/tree/maven2/DependencyTreeBuilderTest.java
deleted file mode 100644 (file)
index 948dab0..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-package org.apache.archiva.dependency.tree.maven2;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- */
-
-import junit.framework.TestCase;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.Configuration;
-import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.archiva.maven2.model.TreeEntry;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.apache.maven.shared.dependency.tree.traversal.DependencyNodeVisitor;
-import org.easymock.MockControl;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.test.context.ContextConfiguration;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import java.io.File;
-import java.util.Collections;
-import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
-
-@RunWith( ArchivaSpringJUnit4ClassRunner.class )
-@ContextConfiguration( locations = {"classpath*:/META-INF/spring-context.xml","classpath:/spring-context.xml"} )
-public class DependencyTreeBuilderTest
-    extends TestCase
-{
-    @Inject
-    @Named (value = "dependencyTreeBuilder#maven2")
-    private DependencyTreeBuilder builder;
-
-    private static final String TEST_REPO_ID = "test";
-
-    private static final String TEST_VERSION = "1.2.1";
-
-    private static final String TEST_ARTIFACT_ID = "archiva-common";
-
-    private static final String TEST_GROUP_ID = "org.apache.archiva";
-
-    private ArtifactFactory artifactFactory;
-
-    @Inject  @Named(value = "archivaConfiguration#test")
-    ArchivaConfiguration config;
-
-    @Before
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        Configuration configuration = new Configuration();
-        ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
-        repoConfig.setId( TEST_REPO_ID );
-        repoConfig.setLocation( new File( "target/test-repository" ).getAbsolutePath() );
-        configuration.addManagedRepository( repoConfig );
-        config.save( configuration );
-
-        artifactFactory = ((DefaultDependencyTreeBuilder)this.builder).getFactory();
-    }
-
-    @Test
-    public void testBuilder()
-        throws DependencyTreeBuilderException
-    {
-        MockControl control = MockControl.createStrictControl( DependencyNodeVisitor.class );
-        DependencyNodeVisitor visitor = (DependencyNodeVisitor) control.getMock();
-
-        DependencyNode springContext =
-            new DependencyNode( createArtifact( "org.springframework", "spring-context", "2.5.6" ) );
-        springContext.setPremanagedVersion( "2.5.5" );
-        DependencyNode springTest =
-            new DependencyNode( createArtifact( "org.springframework", "spring-test", "2.5.5", "test" ) );
-        DependencyNode plexusUtils =
-            new DependencyNode( createArtifact( "org.codehaus.plexus", "plexus-utils", "1.4.5" ) );
-        plexusUtils.setPremanagedVersion( "1.5.1" );
-        DependencyNode slf4jLog4j12 =
-            new DependencyNode( createArtifact( "org.slf4j", "slf4j-log4j12", "1.5.0", "runtime" ) );
-        slf4jLog4j12.setPremanagedScope( "test" );
-        DependencyNode plexusLog4j = new DependencyNode(
-            createArtifact( "org.codehaus.plexus", "plexus-log4j-logging", "1.1-alpha-3", "test" ) );
-        DependencyNode log4j = new DependencyNode( createArtifact( "log4j", "log4j", "1.2.14", "test" ) );
-        DependencyNode mavenArtifact =
-            new DependencyNode( createArtifact( "org.apache.maven", "maven-artifact", "2.0.8", "test" ) );
-        DependencyNode mavenProject =
-            new DependencyNode( createArtifact( "org.apache.maven", "maven-project", "2.0.8", "test" ) );
-        DependencyNode mavenCore =
-            new DependencyNode( createArtifact( "org.apache.maven", "maven-core", "2.0.8", "test" ) );
-        DependencyNode mavenSettings =
-            new DependencyNode( createArtifact( "org.apache.maven", "maven-settings", "2.0.8", "test" ) );
-        DependencyNode mavenModel =
-            new DependencyNode( createArtifact( "org.apache.maven", "maven-model", "2.0.8", "test" ) );
-        DependencyNode plexusCommandLine =
-            new DependencyNode( createArtifact( "org.codehaus.plexus", "plexus-command-line", "1.0-alpha-2", "test" ) );
-        DependencyNode plexusRegistryCommons = new DependencyNode(
-            createArtifact( "org.codehaus.plexus.registry", "plexus-registry-commons", "1.0-alpha-2", "test" ) );
-        plexusRegistryCommons.setPremanagedVersion( "1.0-alpha-3" );
-        DependencyNode plexusRegistryApi = new DependencyNode(
-            createArtifact( "org.codehaus.plexus.registry", "plexus-registry-api", "1.0-alpha-2", "test" ) );
-        plexusRegistryApi.setPremanagedVersion( "1.0-alpha-3" );
-
-        DependencyNode plexusSpring =
-            new DependencyNode( createArtifact( "org.codehaus.plexus", "plexus-spring", "1.2", "test" ) );
-        plexusSpring.addChild( springContext );
-        plexusSpring.addChild( springTest );
-        plexusSpring.addChild( plexusUtils );
-        plexusSpring.addChild( slf4jLog4j12 );
-        plexusSpring.addChild( plexusLog4j );
-        plexusSpring.addChild( log4j );
-        plexusSpring.addChild( mavenArtifact );
-        plexusSpring.addChild( mavenProject );
-        plexusSpring.addChild( mavenCore );
-        plexusSpring.addChild( mavenSettings );
-        plexusSpring.addChild( mavenModel );
-        plexusSpring.addChild( plexusCommandLine );
-        plexusSpring.addChild( plexusRegistryCommons );
-        plexusSpring.addChild( plexusRegistryApi );
-
-        DependencyNode commonsLang = new DependencyNode( createArtifact( "commons-lang", "commons-lang", "2.2" ) );
-        DependencyNode commonsIO = new DependencyNode( createArtifact( "commons-io", "commons-io", "1.4" ) );
-        DependencyNode slf4j = new DependencyNode( createArtifact( "org.slf4j", "slf4j-api", "1.5.0" ) );
-        DependencyNode plexusAPI =
-            new DependencyNode( createArtifact( "org.codehaus.plexus", "plexus-component-api", "1.0-alpha-22" ) );
-        DependencyNode xalan = new DependencyNode( createArtifact( "xalan", "xalan", "2.7.0" ) );
-        DependencyNode dom4j = new DependencyNode( createArtifact( "dom4j", "dom4j", "1.6.1", "test" ) );
-        dom4j.setFailedUpdateScope( "compile" );
-        DependencyNode junit = new DependencyNode( createArtifact( "junit", "junit", "3.8.1", "test" ) );
-        DependencyNode easymock = new DependencyNode( createArtifact( "easymock", "easymock", "1.2_Java1.3", "test" ) );
-        DependencyNode easymockExt =
-            new DependencyNode( createArtifact( "easymock", "easymockclassextension", "1.2", "test" ) );
-
-        DependencyNode mainNode =
-            new DependencyNode( createProjectArtifact( TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION ) );
-        mainNode.addChild( commonsLang );
-        mainNode.addChild( commonsIO );
-        mainNode.addChild( slf4j );
-        mainNode.addChild( plexusAPI );
-        mainNode.addChild( plexusSpring );
-        mainNode.addChild( xalan );
-        mainNode.addChild( dom4j );
-        mainNode.addChild( junit );
-        mainNode.addChild( easymock );
-        mainNode.addChild( easymockExt );
-
-        control.expectAndReturn( visitor.visit( mainNode ), true );
-
-        control.expectAndReturn( visitor.visit( commonsLang ), true );
-        control.expectAndReturn( visitor.endVisit( commonsLang ), true );
-
-        control.expectAndReturn( visitor.visit( commonsIO ), true );
-        control.expectAndReturn( visitor.endVisit( commonsIO ), true );
-
-        control.expectAndReturn( visitor.visit( slf4j ), true );
-        control.expectAndReturn( visitor.endVisit( slf4j ), true );
-
-        control.expectAndReturn( visitor.visit( plexusAPI ), true );
-        control.expectAndReturn( visitor.endVisit( plexusAPI ), true );
-
-        control.expectAndReturn( visitor.visit( plexusSpring ), true );
-
-        control.expectAndReturn( visitor.visit( springContext ), true );
-        control.expectAndReturn( visitor.endVisit( springContext ), true );
-
-        control.expectAndReturn( visitor.visit( springTest ), true );
-        control.expectAndReturn( visitor.endVisit( springTest ), true );
-
-        control.expectAndReturn( visitor.visit( plexusUtils ), true );
-        control.expectAndReturn( visitor.endVisit( plexusUtils ), true );
-
-        control.expectAndReturn( visitor.visit( slf4jLog4j12 ), true );
-        control.expectAndReturn( visitor.endVisit( slf4jLog4j12 ), true );
-
-        control.expectAndReturn( visitor.visit( plexusLog4j ), true );
-        control.expectAndReturn( visitor.endVisit( plexusLog4j ), true );
-
-        control.expectAndReturn( visitor.visit( log4j ), true );
-        control.expectAndReturn( visitor.endVisit( log4j ), true );
-
-        control.expectAndReturn( visitor.visit( mavenArtifact ), true );
-        control.expectAndReturn( visitor.endVisit( mavenArtifact ), true );
-
-        control.expectAndReturn( visitor.visit( mavenProject ), true );
-        control.expectAndReturn( visitor.endVisit( mavenProject ), true );
-
-        control.expectAndReturn( visitor.visit( mavenCore ), true );
-        control.expectAndReturn( visitor.endVisit( mavenCore ), true );
-
-        control.expectAndReturn( visitor.visit( mavenSettings ), true );
-        control.expectAndReturn( visitor.endVisit( mavenSettings ), true );
-
-        control.expectAndReturn( visitor.visit( mavenModel ), true );
-        control.expectAndReturn( visitor.endVisit( mavenModel ), true );
-
-        control.expectAndReturn( visitor.visit( plexusCommandLine ), true );
-        control.expectAndReturn( visitor.endVisit( plexusCommandLine ), true );
-
-        control.expectAndReturn( visitor.visit( plexusRegistryCommons ), true );
-        control.expectAndReturn( visitor.endVisit( plexusRegistryCommons ), true );
-
-        control.expectAndReturn( visitor.visit( plexusRegistryApi ), true );
-        control.expectAndReturn( visitor.endVisit( plexusRegistryApi ), true );
-
-        control.expectAndReturn( visitor.endVisit( plexusSpring ), true );
-
-        control.expectAndReturn( visitor.visit( xalan ), true );
-        control.expectAndReturn( visitor.endVisit( xalan ), true );
-
-        control.expectAndReturn( visitor.visit( dom4j ), true );
-        control.expectAndReturn( visitor.endVisit( dom4j ), true );
-
-        control.expectAndReturn( visitor.visit( junit ), true );
-        control.expectAndReturn( visitor.endVisit( junit ), true );
-
-        control.expectAndReturn( visitor.visit( easymock ), true );
-        control.expectAndReturn( visitor.endVisit( easymock ), true );
-
-        control.expectAndReturn( visitor.visit( easymockExt ), true );
-        control.expectAndReturn( visitor.endVisit( easymockExt ), true );
-
-        control.expectAndReturn( visitor.endVisit( mainNode ), true );
-
-        control.replay();
-
-        builder.buildDependencyTree( Collections.singletonList( TEST_REPO_ID ), TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                     TEST_VERSION, visitor );
-
-        control.verify();
-    }
-
-    private Artifact createProjectArtifact( String groupId, String artifactId, String version )
-    {
-        return artifactFactory.createProjectArtifact( groupId, artifactId, version );
-    }
-
-    private Artifact createArtifact( String groupId, String artifactId, String version, String scope )
-    {
-        return artifactFactory.createDependencyArtifact( groupId, artifactId, VersionRange.createFromVersion( version ),
-                                                         "jar", null, scope );
-    }
-
-    private Artifact createArtifact( String groupId, String artifactId, String version )
-    {
-        return createArtifact( groupId, artifactId, version, Artifact.SCOPE_COMPILE );
-    }
-
-    @Test
-    public void testBuilderMissingDependency()
-        throws DependencyTreeBuilderException
-    {
-        MockControl control = MockControl.createStrictControl( DependencyNodeVisitor.class );
-        DependencyNodeVisitor visitor = (DependencyNodeVisitor) control.getMock();
-
-        // not visited
-
-        control.replay();
-
-        builder.buildDependencyTree( Collections.singletonList( TEST_REPO_ID ), TEST_GROUP_ID, TEST_ARTIFACT_ID,
-                                     "not-a-version", visitor );
-
-        control.verify();
-    }
-
-}
diff --git a/pom.xml b/pom.xml
index 702dc8bde34095ccc701a322901d7101257f3375..bfb11a3a3c99aca22e534a06df74b8b9bfdbe0d3 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -64,7 +64,6 @@
     <maven.version>2.0.8</maven.version>
     <aether.version>1.13.1</aether.version>
 
-    <maven-dependency-tree.version>2.0-SNAPSHOT</maven-dependency-tree.version>
     <maven-model-converter.version>2.1</maven-model-converter.version>
     <maven.indexer.version>4.1.3</maven.indexer.version>
     <wagon.version>2.2</wagon.version>
           </exclusion>
         </exclusions>
       </dependency>
-      <dependency>
-        <groupId>org.apache.maven.shared</groupId>
-        <artifactId>maven-dependency-tree</artifactId>
-        <version>${maven-dependency-tree.version}</version>
-        <exclusions>
-          <exclusion>
-            <groupId>org.codehaus.plexus</groupId>
-            <artifactId>plexus-container-default</artifactId>
-          </exclusion>
-        </exclusions>
-      </dependency>
 
       <dependency>
         <groupId>net.sf.ehcache</groupId>