Example usage for org.apache.maven.artifact.metadata ResolutionGroup getArtifacts

List of usage examples for org.apache.maven.artifact.metadata ResolutionGroup getArtifacts

Introduction

In this page you can find the example usage for org.apache.maven.artifact.metadata ResolutionGroup getArtifacts.

Prototype

public Set<Artifact> getArtifacts() 

Source Link

Usage

From source file:com.adviser.maven.GraphArtifactCollector.java

License:Apache License

private void recurse(ResolutionNode node, Map resolvedArtifacts, Map managedVersions,
        ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source,
        ArtifactFilter filter, List listeners)
        throws CyclicDependencyException, ArtifactResolutionException, OverConstrainedVersionException {
    fireEvent(ResolutionListener.TEST_ARTIFACT, listeners, node);

    // TODO: use as a conflict resolver
    Object key = node.getKey();/*from w ww.  ja va 2  s  .c om*/
    if (managedVersions.containsKey(key)) {
        Artifact artifact = (Artifact) managedVersions.get(key);
        fireEvent(ResolutionListener.MANAGE_ARTIFACT, listeners, node, artifact);
        if (artifact.getVersion() != null) {
            node.getArtifact().setVersion(artifact.getVersion());
        }
        if (artifact.getScope() != null) {
            node.getArtifact().setScope(artifact.getScope());
        }
    }

    List previousNodes = (List) resolvedArtifacts.get(key);
    if (previousNodes != null) {
        node = checkPreviousNodes(node, listeners, previousNodes);
    } else {
        previousNodes = new ArrayList();
        resolvedArtifacts.put(key, previousNodes);
    }
    previousNodes.add(node);

    if (node.isActive()) {
        fireEvent(ResolutionListener.INCLUDE_ARTIFACT, listeners, node);
    }

    // don't pull in the transitive deps of a system-scoped dependency.
    if (node.isActive() && !Artifact.SCOPE_SYSTEM.equals(node.getArtifact().getScope())) {
        fireEvent(ResolutionListener.PROCESS_CHILDREN, listeners, node);
        for (Iterator i = node.getChildrenIterator(); i.hasNext();) {
            ResolutionNode child = (ResolutionNode) i.next();
            // We leave in optional ones, but don't pick up its dependencies
            if (!child.isResolved() && (!child.getArtifact().isOptional() || child.isChildOfRootNode())) {
                Artifact artifact = child.getArtifact();
                try {
                    if (artifact.getVersion() == null) {
                        // set the recommended version
                        // TODO: maybe its better to just pass the range
                        // through to retrieval and use a transformation?
                        ArtifactVersion version;
                        version = getArtifactVersion(localRepository, remoteRepositories, source, artifact);

                        artifact.selectVersion(version.toString());
                        fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE, listeners, child);
                    }

                    ResolutionGroup rGroup = source.retrieve(artifact, localRepository, remoteRepositories);

                    // TODO might be better to have source.retreive() throw
                    // a specific exception for this situation
                    // and catch here rather than have it return null
                    if (rGroup == null) {
                        // relocated dependency artifact is declared
                        // excluded, no need to add and recurse further
                        continue;
                    }

                    child.addDependencies(rGroup.getArtifacts(), rGroup.getResolutionRepositories(), filter);
                } catch (CyclicDependencyException e) {
                    // would like to throw this, but we have crappy stuff in
                    // the repo

                    fireEvent(ResolutionListener.OMIT_FOR_CYCLE, listeners,
                            new ResolutionNode(e.getArtifact(), remoteRepositories, child));
                } catch (ArtifactMetadataRetrievalException e) {
                    artifact.setDependencyTrail(node.getDependencyTrail());
                    throw new ArtifactResolutionException(
                            "Unable to get dependency information: " + e.getMessage(), artifact, e);
                }

                recurse(child, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source,
                        filter, listeners);
            }
        }
        fireEvent(ResolutionListener.FINISH_PROCESSING_CHILDREN, listeners, node);
    }
}

From source file:org.apache.felix.karaf.tooling.features.GenerateFeaturesFileMojo.java

License:Apache License

private List<Artifact> getDependencies(Artifact artifact) {
    List<Artifact> list = new ArrayList<Artifact>();
    try {//  ww  w . ja  v  a2 s.  co  m
        ResolutionGroup pom = artifactMetadataSource.retrieve(artifact, localRepo, remoteRepos);
        if (pom != null) {
            list.addAll(pom.getArtifacts());
        }
    } catch (ArtifactMetadataRetrievalException e) {
        getLog().warn("Unable to retrieve metadata for " + artifact + ", not including dependencies for it");
    } catch (InvalidArtifactRTException e) {
        getLog().warn("Unable to retrieve metadata for " + artifact + ", not including dependencies for it");
    }
    return list;
}

From source file:org.eclipse.che.maven.CheArtifactResolver.java

License:Apache License

public ArtifactResolutionResult resolve(ArtifactResolutionRequest request) {
    Artifact rootArtifact = request.getArtifact();
    Set<Artifact> artifacts = request.getArtifactDependencies();
    Map<String, Artifact> managedVersions = request.getManagedVersionMap();
    List<ResolutionListener> listeners = request.getListeners();
    ArtifactFilter collectionFilter = request.getCollectionFilter();
    ArtifactFilter resolutionFilter = request.getResolutionFilter();
    RepositorySystemSession session = getSession(request.getLocalRepository());

    //TODO: hack because metadata isn't generated in m2e correctly and i want to run the maven i have in the workspace
    if (source == null) {
        try {//from   www  .  j  ava 2s .c  o m
            source = container.lookup(ArtifactMetadataSource.class);
        } catch (ComponentLookupException e) {
            // won't happen
        }
    }

    if (listeners == null) {
        listeners = new ArrayList<ResolutionListener>();

        if (logger.isDebugEnabled()) {
            listeners.add(new DebugResolutionListener(logger));
        }

        listeners.add(new WarningResolutionListener(logger));
    }

    ArtifactResolutionResult result = new ArtifactResolutionResult();

    // The root artifact may, or may not be resolved so we need to check before we attempt to resolve.
    // This is often an artifact like a POM that is taken from disk and we already have hold of the
    // file reference. But this may be a Maven Plugin that we need to resolve from a remote repository
    // as well as its dependencies.

    if (request.isResolveRoot() /* && rootArtifact.getFile() == null */) {
        try {
            resolve(rootArtifact, request.getRemoteRepositories(), session);
        } catch (ArtifactResolutionException e) {
            result.addErrorArtifactException(e);
            return result;
        } catch (ArtifactNotFoundException e) {
            result.addMissingArtifact(request.getArtifact());
            return result;
        }
    }

    ArtifactResolutionRequest collectionRequest = request;

    if (request.isResolveTransitively()) {
        MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest(request);

        metadataRequest.setArtifact(rootArtifact);
        metadataRequest.setResolveManagedVersions(managedVersions == null);

        try {
            ResolutionGroup resolutionGroup = source.retrieve(metadataRequest);

            if (managedVersions == null) {
                managedVersions = resolutionGroup.getManagedVersions();
            }

            Set<Artifact> directArtifacts = resolutionGroup.getArtifacts();

            if (artifacts == null || artifacts.isEmpty()) {
                artifacts = directArtifacts;
            } else {
                List<Artifact> allArtifacts = new ArrayList<Artifact>();
                allArtifacts.addAll(artifacts);
                allArtifacts.addAll(directArtifacts);

                Map<String, Artifact> mergedArtifacts = new LinkedHashMap<String, Artifact>();
                for (Artifact artifact : allArtifacts) {
                    String conflictId = artifact.getDependencyConflictId();
                    if (!mergedArtifacts.containsKey(conflictId)) {
                        mergedArtifacts.put(conflictId, artifact);
                    }
                }

                artifacts = new LinkedHashSet<Artifact>(mergedArtifacts.values());
            }

            collectionRequest = new ArtifactResolutionRequest(request);
            collectionRequest.setServers(request.getServers());
            collectionRequest.setMirrors(request.getMirrors());
            collectionRequest.setProxies(request.getProxies());
            collectionRequest.setRemoteRepositories(resolutionGroup.getResolutionRepositories());
        } catch (ArtifactMetadataRetrievalException e) {
            ArtifactResolutionException are = new ArtifactResolutionException(
                    "Unable to get dependency information for " + rootArtifact.getId() + ": " + e.getMessage(),
                    rootArtifact, metadataRequest.getRemoteRepositories(), e);
            result.addMetadataResolutionException(are);
            return result;
        }
    }

    if (artifacts == null || artifacts.isEmpty()) {
        if (request.isResolveRoot()) {
            result.addArtifact(rootArtifact);
        }
        return result;
    }

    // After the collection we will have the artifact object in the result but they will not be resolved yet.
    result = artifactCollector.collect(artifacts, rootArtifact, managedVersions, collectionRequest, source,
            collectionFilter, listeners, null);

    // We have metadata retrieval problems, or there are cycles that have been detected
    // so we give this back to the calling code and let them deal with this information
    // appropriately.

    if (result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations()
            || result.hasCircularDependencyExceptions()) {
        return result;
    }

    if (result.getArtifactResolutionNodes() != null) {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

        CountDownLatch latch = new CountDownLatch(result.getArtifactResolutionNodes().size());

        for (ResolutionNode node : result.getArtifactResolutionNodes()) {
            Artifact artifact = node.getArtifact();

            if (resolutionFilter == null || resolutionFilter.include(artifact)) {
                executor.execute(new ResolveTask(classLoader, latch, artifact, session,
                        node.getRemoteRepositories(), result));
            } else {
                latch.countDown();
            }
        }
        try {
            latch.await();
        } catch (InterruptedException e) {
            result.addErrorArtifactException(
                    new ArtifactResolutionException("Resolution interrupted", rootArtifact, e));
        }
    }

    // We want to send the root artifact back in the result but we need to do this after the other dependencies
    // have been resolved.
    if (request.isResolveRoot()) {
        // Add the root artifact (as the first artifact to retain logical order of class path!)
        Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>();
        allArtifacts.add(rootArtifact);
        allArtifacts.addAll(result.getArtifacts());
        result.setArtifacts(allArtifacts);
    }

    return result;
}

From source file:org.fabric3.runtime.maven.itest.ArtifactHelper.java

License:Open Source License

/**
 * Returns the set of extensions for the given profiles.
 *
 * @param profiles the profiles/*from w ww  . ja  v a2  s .c  o m*/
 * @return the expanded profile set including extensions and remote repositories for transitive dependencies
 * @throws MojoExecutionException if there is an error dereferencing the extensions
 */
@SuppressWarnings({ "unchecked" })
public ExpandedProfiles expandProfileExtensions(Dependency[] profiles) throws MojoExecutionException {
    Set<Dependency> dependencies = new HashSet<Dependency>();
    Set<ArtifactRepository> repositories = new HashSet<ArtifactRepository>();
    try {
        for (Dependency profile : profiles) {
            Artifact artifact = artifactFactory.createArtifact(profile.getGroupId(), profile.getArtifactId(),
                    profile.getVersion(), "compile", "jar");
            ResolutionGroup resolutionGroup = metadataSource.retrieve(artifact, localRepository,
                    remoteRepositories);
            Set<Artifact> extensions = resolutionGroup.getArtifacts();
            for (Artifact extension : extensions) {
                Dependency dependency = new Dependency();
                dependency.setGroupId(extension.getGroupId());
                dependency.setArtifactId(extension.getArtifactId());
                dependency.setVersion(extension.getVersion());
                dependencies.add(dependency);
            }
            for (ArtifactRepository repository : resolutionGroup.getResolutionRepositories()) {
                repositories.add(repository);
            }
        }
    } catch (ArtifactMetadataRetrievalException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }

    return new ExpandedProfiles(dependencies, repositories);
}

From source file:org.fabric3.runtime.maven.itest.ArtifactHelper.java

License:Open Source License

@SuppressWarnings("unchecked")
private Set<Artifact> resolveTransitive(final List<Exclusion> exclusions, Artifact rootArtifact)
        throws MojoExecutionException {
    try {/*from w  w w.  ja  va 2 s. c om*/
        ResolutionGroup resolutionGroup = metadataSource.retrieve(rootArtifact, localRepository,
                remoteRepositories);
        ArtifactFilter filter = new ArtifactFilter() {
            public boolean include(Artifact artifact) {
                String groupId = artifact.getGroupId();
                String artifactId = artifact.getArtifactId();

                for (Exclusion exclusion : exclusions) {
                    if (artifactId.equals(exclusion.getArtifactId())
                            && groupId.equals(exclusion.getGroupId())) {
                        return false;
                    }
                }
                return true;
            }
        };
        Set artifacts = resolutionGroup.getArtifacts();
        ArtifactResolutionResult result = resolver.resolveTransitively(artifacts, rootArtifact,
                Collections.emptyMap(), localRepository, remoteRepositories, metadataSource, filter);
        return result.getArtifacts();

    } catch (ArtifactResolutionException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (ArtifactNotFoundException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    } catch (ArtifactMetadataRetrievalException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }

}

From source file:org.jetbrains.idea.maven.server.embedder.CustomMaven32ArtifactResolver.java

License:Apache License

public ArtifactResolutionResult resolve(ArtifactResolutionRequest request) {
    Artifact rootArtifact = request.getArtifact();
    Set<Artifact> artifacts = request.getArtifactDependencies();
    Map<String, Artifact> managedVersions = request.getManagedVersionMap();
    List<ResolutionListener> listeners = request.getListeners();
    ArtifactFilter collectionFilter = request.getCollectionFilter();
    ArtifactFilter resolutionFilter = request.getResolutionFilter();
    RepositorySystemSession session = getSession(request.getLocalRepository());

    //TODO: hack because metadata isn't generated in m2e correctly and i want to run the maven i have in the workspace
    if (source == null) {
        try {/*from  w  ww. j  av a 2s . c  o m*/
            source = container.lookup(ArtifactMetadataSource.class);
        } catch (ComponentLookupException e) {
            // won't happen
        }
    }

    if (listeners == null) {
        listeners = new ArrayList<ResolutionListener>();

        if (logger.isDebugEnabled()) {
            listeners.add(new DebugResolutionListener(logger));
        }

        listeners.add(new WarningResolutionListener(logger));
    }

    ArtifactResolutionResult result = new ArtifactResolutionResult();

    // The root artifact may, or may not be resolved so we need to check before we attempt to resolve.
    // This is often an artifact like a POM that is taken from disk and we already have hold of the
    // file reference. But this may be a Maven Plugin that we need to resolve from a remote repository
    // as well as its dependencies.

    if (request.isResolveRoot() /* && rootArtifact.getFile() == null */ ) {
        try {
            resolve(rootArtifact, request.getRemoteRepositories(), session);
        } catch (ArtifactResolutionException e) {
            result.addErrorArtifactException(e);
            return result;
        } catch (ArtifactNotFoundException e) {
            result.addMissingArtifact(request.getArtifact());
            return result;
        }
    }

    ArtifactResolutionRequest collectionRequest = request;

    if (request.isResolveTransitively()) {
        MetadataResolutionRequest metadataRequest = new DefaultMetadataResolutionRequest(request);

        metadataRequest.setArtifact(rootArtifact);
        metadataRequest.setResolveManagedVersions(managedVersions == null);

        try {
            ResolutionGroup resolutionGroup = source.retrieve(metadataRequest);

            if (managedVersions == null) {
                managedVersions = resolutionGroup.getManagedVersions();
            }

            Set<Artifact> directArtifacts = resolutionGroup.getArtifacts();

            if (artifacts == null || artifacts.isEmpty()) {
                artifacts = directArtifacts;
            } else {
                List<Artifact> allArtifacts = new ArrayList<Artifact>();
                allArtifacts.addAll(artifacts);
                allArtifacts.addAll(directArtifacts);

                Map<String, Artifact> mergedArtifacts = new LinkedHashMap<String, Artifact>();
                for (Artifact artifact : allArtifacts) {
                    String conflictId = artifact.getDependencyConflictId();
                    if (!mergedArtifacts.containsKey(conflictId)) {
                        mergedArtifacts.put(conflictId, artifact);
                    }
                }

                artifacts = new LinkedHashSet<Artifact>(mergedArtifacts.values());
            }

            collectionRequest = new ArtifactResolutionRequest(request);
            collectionRequest.setServers(request.getServers());
            collectionRequest.setMirrors(request.getMirrors());
            collectionRequest.setProxies(request.getProxies());
            collectionRequest.setRemoteRepositories(resolutionGroup.getResolutionRepositories());
        } catch (ArtifactMetadataRetrievalException e) {
            ArtifactResolutionException are = new ArtifactResolutionException(
                    "Unable to get dependency information for " + rootArtifact.getId() + ": " + e.getMessage(),
                    rootArtifact, metadataRequest.getRemoteRepositories(), e);
            result.addMetadataResolutionException(are);
            return result;
        }
    }

    if (artifacts == null || artifacts.isEmpty()) {
        if (request.isResolveRoot()) {
            result.addArtifact(rootArtifact);
        }
        return result;
    }

    // After the collection we will have the artifact object in the result but they will not be resolved yet.
    result = artifactCollector.collect(artifacts, rootArtifact, managedVersions, collectionRequest, source,
            collectionFilter, listeners, null);

    // We have metadata retrieval problems, or there are cycles that have been detected
    // so we give this back to the calling code and let them deal with this information
    // appropriately.

    if (result.hasMetadataResolutionExceptions() || result.hasVersionRangeViolations()
            || result.hasCircularDependencyExceptions()) {
        return result;
    }

    if (result.getArtifactResolutionNodes() != null) {
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

        CountDownLatch latch = new CountDownLatch(result.getArtifactResolutionNodes().size());

        for (ResolutionNode node : result.getArtifactResolutionNodes()) {
            Artifact artifact = node.getArtifact();

            if (resolutionFilter == null || resolutionFilter.include(artifact)) {
                executor.execute(new ResolveTask(classLoader, latch, artifact, session,
                        node.getRemoteRepositories(), result));
            } else {
                latch.countDown();
            }
        }
        try {
            latch.await();
        } catch (InterruptedException e) {
            result.addErrorArtifactException(
                    new ArtifactResolutionException("Resolution interrupted", rootArtifact, e));
        }
    }

    // We want to send the root artifact back in the result but we need to do this after the other dependencies
    // have been resolved.
    if (request.isResolveRoot()) {
        // Add the root artifact (as the first artifact to retain logical order of class path!)
        Set<Artifact> allArtifacts = new LinkedHashSet<Artifact>();
        allArtifacts.add(rootArtifact);
        allArtifacts.addAll(result.getArtifacts());
        result.setArtifacts(allArtifacts);
    }

    return result;
}

From source file:org.jvnet.maven.plugin.antrun.MavenComponentBag.java

License:Apache License

public ArtifactResolutionResult resolveTransitively(String groupId, String artifactId, String version,
        String type, String classifier)
        throws ArtifactResolutionException, ArtifactNotFoundException, IOException {
    Set artifacts = new HashSet();
    Artifact artifact = createArtifactWithClassifier(groupId, artifactId, version, type, classifier);
    ResolutionGroup resolutionGroup;
    try {/*from   w  w w .j a v a 2 s .co  m*/
        resolutionGroup = artifactMetadataSource.retrieve(artifact, localRepository,
                project.getPluginArtifactRepositories());
        artifacts.addAll(resolutionGroup.getArtifacts());
    } catch (ArtifactMetadataRetrievalException e) {
        throw new ArtifactResolutionException("Unable to download metadata from repository for artifact '"
                + artifact.getId() + " " + e.getMessage(), artifact);
    }
    ArtifactResolutionResult result = resolver.resolveTransitively(artifacts, artifact, localRepository,
            remoteRepositories, artifactMetadataSource, new ScopeArtifactFilter("runtime"));
    return result;
}

From source file:org.universAAL.maven.treebuilder.DependencyTreeBuilder.java

License:Apache License

/**
 * Method resolves provided node with the use of provided
 * ArtifactMetadataSource and taking into account ManagedVersionMap. Output
 * is passed to listeners, passed as argument, which are notified about all
 * events related to dependencies detected in the tree.
 * /*from  ww w  .j a  v a2 s.  c  o m*/
 * @param parentNode
 *            Parent node
 * @param child
 *            Child node
 * @param filter
 *            Filter for filtering artifacts for the resolving process.
 * @param managedVersions
 *            Map of managed versions.
 * @param listener
 *            Listener to be notified about events related to resolution
 *            process.
 * @param source
 *            ArtifactMetadataSource object passed by maven.
 * @param parentArtifact
 *            Parent artifact
 * @return returns true if the child should be recursively resolved.
 * @throws OverConstrainedVersionException
 *             Occurs when ranges exclude each other and no valid value
 *             remains.
 * @throws ArtifactMetadataRetrievalException
 *             Error while retrieving repository metadata from the
 *             repository
 */
private boolean resolveChildNode(final ResolutionNode parentNode, final ResolutionNode child,
        final ArtifactFilter filter, final ManagedVersionMap managedVersions,
        final DependencyTreeResolutionListener listener, final ArtifactMetadataSource source,
        final Artifact parentArtifact)
        throws OverConstrainedVersionException, ArtifactMetadataRetrievalException {
    // We leave in optional ones, but don't pick up its dependencies
    if (!child.isResolved() && (!child.getArtifact().isOptional() || child.isChildOfRootNode())) {
        Artifact artifact = child.getArtifact();
        artifact.setDependencyTrail(parentNode.getDependencyTrail());

        List childRemoteRepositories = child.getRemoteRepositories();
        try {
            Object childKey;
            do {
                childKey = child.getKey();

                if (managedVersions.containsKey(childKey)) {
                    // If this child node is a managed dependency,
                    // ensure
                    // we are using the dependency management
                    // version
                    // of this child if applicable b/c we want to
                    // use the
                    // managed version's POM, *not* any other
                    // version's POM.
                    // We retrieve the POM below in the retrieval
                    // step.
                    manageArtifact(child, managedVersions);

                    // Also, we need to ensure that any exclusions
                    // it presents are
                    // added to the artifact before we retrieve the
                    // metadata
                    // for the artifact; otherwise we may end up
                    // with unwanted
                    // dependencies.
                    Artifact ma = (Artifact) managedVersions.get(childKey);
                    ArtifactFilter managedExclusionFilter = ma.getDependencyFilter();
                    if (null != managedExclusionFilter) {
                        if (null != artifact.getDependencyFilter()) {
                            AndArtifactFilter aaf = new AndArtifactFilter();
                            aaf.add(artifact.getDependencyFilter());
                            aaf.add(managedExclusionFilter);
                            artifact.setDependencyFilter(aaf);
                        } else {
                            artifact.setDependencyFilter(managedExclusionFilter);
                        }
                    }
                }

                if (artifact.getVersion() == null) {
                    // set the recommended version
                    // TODO: maybe its better to just pass the range
                    // through to retrieval and use a
                    // transformation?
                    ArtifactVersion version;
                    if (artifact.isSelectedVersionKnown()) {
                        version = artifact.getSelectedVersion();
                    } else {
                        // go find the version
                        List versions = artifact.getAvailableVersions();
                        if (versions == null) {
                            versions = source.retrieveAvailableVersions(artifact, localRepository,
                                    childRemoteRepositories);
                            artifact.setAvailableVersions(versions);
                        }

                        Collections.sort(versions);

                        VersionRange versionRange = artifact.getVersionRange();

                        version = versionRange.matchVersion(versions);

                        if (version == null) {
                            if (versions.isEmpty()) {
                                throw new OverConstrainedVersionException(
                                        "No versions are present in the repository for the artifact with a range "
                                                + versionRange,
                                        artifact, childRemoteRepositories);
                            }

                            throw new OverConstrainedVersionException("Couldn't find a version in " + versions
                                    + " to match range " + versionRange, artifact, childRemoteRepositories);
                        }
                    }

                    // this is dangerous because
                    // artifact.getSelectedVersion() can
                    // return null. However it is ok here because we
                    // first check if the
                    // selected version is known. As currently coded
                    // we can't get a null here.
                    artifact.selectVersion(version.toString());
                    fireEvent(ResolutionListener.SELECT_VERSION_FROM_RANGE, listener, child);
                }

                // rotgier: it is not compatible with maven 3
                // Artifact relocated = source.retrieveRelocatedArtifact(
                // artifact, localRepository, childRemoteRepositories);
                // if (relocated != null && !artifact.equals(relocated)) {
                // relocated.setDependencyFilter(artifact
                // .getDependencyFilter());
                // artifact = relocated;
                // child.setArtifact(artifact);
                // }
            } while (!childKey.equals(child.getKey()));

            if (parentArtifact != null && parentArtifact.getDependencyFilter() != null
                    && !parentArtifact.getDependencyFilter().include(artifact)) {
                // MNG-3769: the [probably relocated] artifact is
                // excluded.
                // We could process exclusions on relocated artifact
                // details in the
                // MavenMetadataSource.createArtifacts(..) step, BUT
                // that would
                // require resolving the POM from the repository
                // very early on in
                // the build.
                return true;
            }

            ResolutionGroup rGroup = source.retrieve(artifact, localRepository, childRemoteRepositories);

            // TODO might be better to have source.retrieve() throw
            // a specific exception for this situation
            // and catch here rather than have it return null
            if (rGroup == null) {
                // relocated dependency artifact is declared
                // excluded, no need to add and recurse further
                return true;
            }
            child.addDependencies(rGroup.getArtifacts(), rGroup.getResolutionRepositories(), filter);

        } catch (CyclicDependencyException e) {
            // would like to throw this, but we have crappy stuff in
            // the repo

            fireEvent(ResolutionListener.OMIT_FOR_CYCLE, listener,
                    new ResolutionNode(e.getArtifact(), childRemoteRepositories, child));
        } catch (ArtifactMetadataRetrievalException e) {
            artifact.setDependencyTrail(parentNode.getDependencyTrail());
            throw e;
        }
    } else {
        return true;
    }
    return false;
}