Example usage for org.apache.maven.project MavenProject getDependencyArtifacts

List of usage examples for org.apache.maven.project MavenProject getDependencyArtifacts

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getDependencyArtifacts.

Prototype

@Deprecated
public Set<Artifact> getDependencyArtifacts() 

Source Link

Document

Direct dependencies that this project has.

Usage

From source file:org.jszip.maven.RunMojo.java

License:Apache License

private void addCssEngineResources(MavenProject project, List<MavenProject> reactorProjects, Mapping[] mappings,
        List<Resource> _resources) throws MojoExecutionException, IOException {
    List<PseudoFileSystem.Layer> layers = new ArrayList<PseudoFileSystem.Layer>();
    layers.add(new PseudoFileSystem.FileLayer("/virtual", warSourceDirectory));
    FilterArtifacts filter = new FilterArtifacts();

    filter.addFilter(new ProjectTransitivityFilter(project.getDependencyArtifacts(), false));

    filter.addFilter(new ScopeFilter("runtime", ""));

    filter.addFilter(new TypeFilter(JSZIP_TYPE, ""));

    // start with all artifacts.
    Set<Artifact> artifacts = project.getArtifacts();

    // perform filtering
    try {/*from  www . j  a  v  a 2  s .  c  o  m*/
        artifacts = filter.filter(artifacts);
    } catch (ArtifactFilterException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }

    for (Artifact artifact : artifacts) {
        String path = Mapping.getArtifactPath(mappings, artifact);
        getLog().info("Adding " + ArtifactUtils.key(artifact) + " to virtual filesystem");
        File file = artifact.getFile();
        if (file.isDirectory()) {
            MavenProject fromReactor = findProject(reactorProjects, artifact);
            if (fromReactor != null) {
                MavenSession session = this.session.clone();
                session.setCurrentProject(fromReactor);
                Plugin plugin = findThisPluginInProject(fromReactor);
                try {
                    // we cheat here and use our version of the plugin... but this is less of a cheat than the only
                    // other way which is via reflection.
                    MojoDescriptor jszipDescriptor = findMojoDescriptor(this.pluginDescriptor, JSZipMojo.class);

                    for (PluginExecution pluginExecution : plugin.getExecutions()) {
                        if (!pluginExecution.getGoals().contains(jszipDescriptor.getGoal())) {
                            continue;
                        }
                        MojoExecution mojoExecution = createMojoExecution(plugin, pluginExecution,
                                jszipDescriptor);
                        JSZipMojo mojo = (JSZipMojo) mavenPluginManager
                                .getConfiguredMojo(org.apache.maven.plugin.Mojo.class, session, mojoExecution);
                        try {
                            File contentDirectory = mojo.getContentDirectory();
                            if (contentDirectory.isDirectory()) {
                                getLog().debug("Merging directory " + contentDirectory + " into " + path);
                                layers.add(new PseudoFileSystem.FileLayer(path, contentDirectory));
                            }
                            File resourcesDirectory = mojo.getResourcesDirectory();
                            if (resourcesDirectory.isDirectory()) {
                                getLog().debug("Merging directory " + contentDirectory + " into " + path);
                                layers.add(new PseudoFileSystem.FileLayer(path, resourcesDirectory));
                            }
                        } finally {
                            mavenPluginManager.releaseMojo(mojo, mojoExecution);
                        }
                    }
                } catch (PluginConfigurationException e) {
                    throw new MojoExecutionException(e.getMessage(), e);
                } catch (PluginContainerException e) {
                    throw new MojoExecutionException(e.getMessage(), e);
                }
            } else {
                throw new MojoExecutionException("Cannot find jzsip artifact: " + artifact.getId());
            }
        } else {
            try {
                getLog().debug("Merging .zip file " + file + " into " + path);
                layers.add(new PseudoFileSystem.ZipLayer(path, file));
            } catch (IOException e) {
                throw new MojoExecutionException(e.getMessage(), e);
            }
        }
    }

    final PseudoFileSystem fs = new PseudoFileSystem(layers);

    CssEngine engine = new LessEngine(fs, encoding == null ? "utf-8" : encoding, getLog(), lessCompress,
            customLessScript, showErrorExtracts);

    // look for files to compile

    PseudoDirectoryScanner scanner = new PseudoDirectoryScanner();

    scanner.setFileSystem(fs);

    scanner.setBasedir(fs.getPseudoFile("/virtual"));

    if (lessIncludes != null && !lessIncludes.isEmpty()) {
        scanner.setIncludes(processIncludesExcludes(lessIncludes));
    } else {
        scanner.setIncludes(new String[] { "**/*.less" });
    }

    if (lessExcludes != null && !lessExcludes.isEmpty()) {
        scanner.setExcludes(processIncludesExcludes(lessExcludes));
    } else {
        scanner.setExcludes(new String[0]);
    }

    scanner.scan();

    for (String fileName : new ArrayList<String>(Arrays.asList(scanner.getIncludedFiles()))) {
        final CssEngineResource child = new CssEngineResource(fs, engine, "/virtual/" + fileName,
                new File(webappDirectory, engine.mapName(fileName)));
        final String path = FileUtils.dirname(fileName);
        if (StringUtils.isBlank(path)) {
            _resources.add(
                    new VirtualDirectoryResource(new VirtualDirectoryResource(child, child.getName()), ""));
        } else {
            _resources.add(
                    new VirtualDirectoryResource(new VirtualDirectoryResource(child, child.getName()), path));
        }
    }

    engine = new SassEngine(fs, encoding == null ? "utf-8" : encoding);

    if (sassIncludes != null && !sassIncludes.isEmpty()) {
        scanner.setIncludes(processIncludesExcludes(sassIncludes));
    } else {
        scanner.setIncludes(new String[] { "**/*.sass", "**/*.scss" });
    }

    if (sassExcludes != null && !sassExcludes.isEmpty()) {
        scanner.setExcludes(processIncludesExcludes(sassExcludes));
    } else {
        scanner.setExcludes(new String[] { "**/_*.sass", "**/_*.scss" });
    }

    scanner.scan();

    for (String fileName : new ArrayList<String>(Arrays.asList(scanner.getIncludedFiles()))) {
        final CssEngineResource child = new CssEngineResource(fs, engine, "/virtual/" + fileName,
                new File(webappDirectory, engine.mapName(fileName)));
        final String path = FileUtils.dirname(fileName);
        if (StringUtils.isBlank(path)) {
            _resources.add(
                    new VirtualDirectoryResource(new VirtualDirectoryResource(child, child.getName()), ""));
        } else {
            _resources.add(
                    new VirtualDirectoryResource(new VirtualDirectoryResource(child, child.getName()), path));
        }
    }

}

From source file:org.jszip.maven.RunMojo.java

License:Apache License

@SuppressWarnings("unchecked")
private Set<Artifact> getOverlayArtifacts(MavenProject project, String scope) throws ArtifactFilterException {
    FilterArtifacts filter = new FilterArtifacts();

    filter.addFilter(new ProjectTransitivityFilter(project.getDependencyArtifacts(), false));

    filter.addFilter(new ScopeFilter(scope, ""));

    filter.addFilter(new TypeFilter(JSZIP_TYPE, ""));

    return filter.filter(project.getArtifacts());
}

From source file:org.linuxstuff.mojo.licensing.DefaultDependenciesTool.java

License:Open Source License

/**
 * {@inheritDoc}// w ww.ja  v a  2  s.c om
 */
@Override
public SortedMap<String, MavenProject> loadProjectDependencies(MavenProject project,
        MavenProjectDependenciesConfigurator configuration, ArtifactRepository localRepository,
        List<ArtifactRepository> remoteRepositories, SortedMap<String, MavenProject> cache) {

    boolean haveNoIncludedGroups = StringUtils.isEmpty(configuration.getIncludedGroups());
    boolean haveNoIncludedArtifacts = StringUtils.isEmpty(configuration.getIncludedArtifacts());

    boolean haveExcludedGroups = StringUtils.isNotEmpty(configuration.getExcludedGroups());
    boolean haveExcludedArtifacts = StringUtils.isNotEmpty(configuration.getExcludedArtifacts());
    boolean haveExclusions = haveExcludedGroups || haveExcludedArtifacts;

    Pattern includedGroupPattern = null;
    Pattern includedArtifactPattern = null;
    Pattern excludedGroupPattern = null;
    Pattern excludedArtifactPattern = null;

    if (!haveNoIncludedGroups) {
        includedGroupPattern = Pattern.compile(configuration.getIncludedGroups());
    }
    if (!haveNoIncludedArtifacts) {
        includedArtifactPattern = Pattern.compile(configuration.getIncludedArtifacts());
    }
    if (haveExcludedGroups) {
        excludedGroupPattern = Pattern.compile(configuration.getExcludedGroups());
    }
    if (haveExcludedArtifacts) {
        excludedArtifactPattern = Pattern.compile(configuration.getExcludedArtifacts());
    }

    Set<?> depArtifacts;

    if (configuration.isIncludeTransitiveDependencies()) {
        // All project dependencies
        depArtifacts = project.getArtifacts();
    } else {
        // Only direct project dependencies
        depArtifacts = project.getDependencyArtifacts();
    }

    List<String> includedScopes = configuration.getIncludedScopes();
    List<String> excludeScopes = configuration.getExcludedScopes();

    SortedMap<String, MavenProject> result = new TreeMap<String, MavenProject>();

    for (Object o : depArtifacts) {
        Artifact artifact = (Artifact) o;

        String scope = artifact.getScope();
        if (!includedScopes.isEmpty() && !includedScopes.contains(scope)) {

            // not in included scopes
            continue;
        }
        {
            if (excludeScopes.contains(scope)) {

                // in excluded scopes
                continue;
            }
        }

        Logger log = getLogger();

        String id = artifact.getId();

        log.debug("detected artifact " + id);

        // Check if the project should be included
        // If there is no specified artifacts and group to include, include
        // all
        boolean isToInclude = haveNoIncludedArtifacts && haveNoIncludedGroups
                || isIncludable(artifact, includedGroupPattern, includedArtifactPattern);

        // Check if the project should be excluded
        boolean isToExclude = isToInclude && haveExclusions
                && isExcludable(artifact, excludedGroupPattern, excludedArtifactPattern);

        if (!isToInclude || isToExclude) {
            log.debug("skip artifact " + id);
            continue;
        }

        MavenProject depMavenProject = null;

        if (cache != null) {

            // try to get project from cache
            depMavenProject = cache.get(id);
        }

        if (depMavenProject != null) {
            log.debug("add dependency [" + id + "] (from cache)");
        } else {

            // build project

            try {
                depMavenProject = mavenProjectBuilder.buildFromRepository(artifact, remoteRepositories,
                        localRepository, true);
            } catch (ProjectBuildingException e) {
                log.warn("Unable to obtain POM for artifact : " + artifact, e);
                continue;
            }

            log.debug("add dependency [" + id + "]");
            if (cache != null) {

                // store it also in cache
                cache.put(id, depMavenProject);
            }
        }

        // keep the project
        result.put(id, depMavenProject);
    }

    return result;
}

From source file:org.nuxeo.build.maven.AntBuildMojo.java

License:Open Source License

@Override
public void resolveDependencyTree(Artifact artifact, ArtifactFilter filter, ResolutionListener listener)
        throws ArtifactResolutionException, ProjectBuildingException {
    MavenProject mavenProject = projectBuilder.buildFromRepository(artifact, remoteRepositories,
            localRepository);/*w ww.  j a  va2s.  c om*/
    ArtifactCollector collector = new DefaultArtifactCollector();
    collector.collect(mavenProject.getDependencyArtifacts(), mavenProject.getArtifact(),
            mavenProject.getManagedVersionMap(), localRepository, mavenProject.getRemoteArtifactRepositories(),
            metadataSource, filter, Collections.singletonList(listener));
}

From source file:org.nuxeo.build.maven.EmbeddedMavenClient.java

License:Open Source License

public void resolveDependencyTree(Artifact artifact, ArtifactFilter filter, ResolutionListener listener)
        throws ArtifactResolutionException, ProjectBuildingException {
    MavenProject project = mavenProjectBuilder.buildFromRepository(artifact, getRemoteRepositories(),
            localRepository);//from w w  w. j a  va2s . c  om

    @SuppressWarnings("rawtypes")
    Set dependencyArtifacts = project.getDependencyArtifacts();
    if (dependencyArtifacts == null) {
        try {
            dependencyArtifacts = project.createArtifacts(artifactFactory, null, null);
        } catch (InvalidDependencyVersionException e) {
            throw new ArtifactResolutionException("Cannot set dependencies", artifact, e);
        }
        project.setDependencyArtifacts(dependencyArtifacts);
    }

    ArtifactCollector collector = new DefaultArtifactCollector();
    collector.collect(dependencyArtifacts, project.getArtifact(), project.getManagedVersionMap(),
            localRepository, project.getRemoteArtifactRepositories(), artifactMetadataSource, filter,
            Collections.singletonList(listener));
}

From source file:org.onos.yangtools.yang2sources.plugin.Util.java

License:Open Source License

/**
 * Read current project dependencies and check if it don't grab incorrect
 * artifacts versions which could be in conflict with plugin dependencies.
 *
 * @param project//from   ww  w  .j av  a 2 s.  c o  m
 *            current project
 * @param repoSystem
 *            repository system
 * @param localRepo
 *            local repository
 * @param remoteRepos
 *            remote repositories
 * @param log
 *            logger
 */
static void checkClasspath(MavenProject project, RepositorySystem repoSystem, ArtifactRepository localRepo,
        List<ArtifactRepository> remoteRepos, Log log) {
    Plugin plugin = project.getPlugin(YangToSourcesMojo.PLUGIN_NAME);
    if (plugin == null) {
        log.warn(message("%s not found, dependencies version check skipped", YangToSourcesProcessor.LOG_PREFIX,
                YangToSourcesMojo.PLUGIN_NAME));
    } else {
        Map<Artifact, Collection<Artifact>> pluginDependencies = new HashMap<>();
        getPluginTransitiveDependencies(plugin, pluginDependencies, repoSystem, localRepo, remoteRepos, log);

        Set<Artifact> projectDependencies = project.getDependencyArtifacts();
        for (Map.Entry<Artifact, Collection<Artifact>> entry : pluginDependencies.entrySet()) {
            checkArtifact(entry.getKey(), projectDependencies, log);
            for (Artifact dependency : entry.getValue()) {
                checkArtifact(dependency, projectDependencies, log);
            }
        }
    }
}

From source file:org.opencredo.maven.plugins.enforcer.AbstractBanDependenciesBase.java

License:Apache License

/**
 * Execute the rule.//  ww w. j a  v a 2  s.  c o m
 *
 * @param helper the helper
 * @throws EnforcerRuleException the enforcer rule exception
 */
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
    // get the project
    MavenProject project = null;
    DependencyTreePrinter dependencyTreePrinter = null;
    try {
        project = (MavenProject) helper.evaluate("${project}");
        ArtifactRepository localRepository = (ArtifactRepository) helper.evaluate("${localRepository}");
        ArtifactFactory artifactFactory = (ArtifactFactory) helper.getComponent(ArtifactFactory.class);
        ArtifactCollector artifactCollector = (ArtifactCollector) helper.getComponent(ArtifactCollector.class);
        ArtifactMetadataSource artifactMetadataSource = (ArtifactMetadataSource) helper
                .getComponent(ArtifactMetadataSource.class);
        DependencyTreeBuilder dependencyTreeBuilder = (DependencyTreeBuilder) helper
                .getComponent(DependencyTreeBuilder.class);
        dependencyTreePrinter = new DefaultDependencyTreePrinter(project, localRepository, artifactFactory,
                artifactMetadataSource, artifactCollector, dependencyTreeBuilder);
    } catch (Exception eee) {
        throw new EnforcerRuleException("Unable to retrieve the rule dependencies: ", eee);
    }

    // get the correct list of dependencies
    Set dependencies = null;
    if (searchTransitive) {
        dependencies = project.getArtifacts();
    } else {
        dependencies = project.getDependencyArtifacts();
    }

    executeInternal(new DependencyRuleContext(project, helper, dependencyTreePrinter), dependencies);
}

From source file:org.opendaylight.yangtools.yang2sources.plugin.Util.java

License:Open Source License

/**
 * Read current project dependencies and check if it don't grab incorrect
 * artifacts versions which could be in conflict with plugin dependencies.
 *
 * @param project/*from www . ja  v  a2 s .  c o m*/
 *            current project
 * @param repoSystem
 *            repository system
 * @param localRepo
 *            local repository
 * @param remoteRepos
 *            remote repositories
 */
static void checkClasspath(final MavenProject project, final RepositorySystem repoSystem,
        final ArtifactRepository localRepo, final List<ArtifactRepository> remoteRepos) {
    Plugin plugin = project.getPlugin(YangToSourcesMojo.PLUGIN_NAME);
    if (plugin == null) {
        LOG.warn("{} {} not found, dependencies version check skipped", YangToSourcesProcessor.LOG_PREFIX,
                YangToSourcesMojo.PLUGIN_NAME);
    } else {
        Map<Artifact, Collection<Artifact>> pluginDependencies = new HashMap<>();
        getPluginTransitiveDependencies(plugin, pluginDependencies, repoSystem, localRepo, remoteRepos);

        Set<Artifact> projectDependencies = project.getDependencyArtifacts();
        for (Map.Entry<Artifact, Collection<Artifact>> entry : pluginDependencies.entrySet()) {
            checkArtifact(entry.getKey(), projectDependencies);
            for (Artifact dependency : entry.getValue()) {
                checkArtifact(dependency, projectDependencies);
            }
        }
    }
}

From source file:org.sonatype.flexmojos.utilities.MavenUtils.java

License:Apache License

/**
 * Get dependency artifacts for a project using the local and remote repositories to resolve the artifacts
 * //from   w  w w .j  a va  2 s.c o  m
 * @param project maven project
 * @param resolver artifact resolver
 * @param localRepository artifact repository
 * @param remoteRepositories List of remote repositories
 * @param artifactMetadataSource artifactMetadataSource
 * @param artifactFactory TODO
 * @return all dependencies from the project
 * @throws MojoExecutionException thrown if an exception occured during artifact resolving
 */
@SuppressWarnings("unchecked")
public static Set<Artifact> getDependencyArtifacts(MavenProject project, ArtifactResolver resolver,
        ArtifactRepository localRepository, List remoteRepositories,
        ArtifactMetadataSource artifactMetadataSource, ArtifactFactory artifactFactory)
        throws MojoExecutionException {
    Set<Artifact> artifacts = project.getDependencyArtifacts();
    if (artifacts == null) {
        try {
            artifacts = project.createArtifacts(artifactFactory, null, null);
        } catch (InvalidDependencyVersionException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
        project.setDependencyArtifacts(artifacts);
    }

    ArtifactResolutionResult arr;
    try {
        arr = resolver.resolveTransitively(project.getDependencyArtifacts(), project.getArtifact(),
                remoteRepositories, localRepository, artifactMetadataSource);
    } catch (AbstractArtifactResolutionException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }

    Set<Artifact> result = arr.getArtifacts();

    // ## 6/18/09 StoneRiver Change to resolve RELEASE Artifact version ##
    for (Artifact artifact : result) {
        if (artifact.getVersion().equals(Artifact.RELEASE_VERSION)) {
            getReleaseVersion(artifact, localRepository, remoteRepositories, artifactMetadataSource);
        }
    }

    return result;

}

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

License:Apache License

/**
 * Method builds dependency tree for a list of maven projects. All artifacts
 * in the tree are crosschecked against duplications and conflicts. In each
 * case of duplication, conflict, the case is resolved by omitting artifact
 * which is lower in the tree and keeping artifact which is higher in the
 * tree. If artifacts are on the same level then the one occuring first in
 * the tree is kept.//  w  w w  .  j  av a  2s. c  om
 * 
 * @param repository
 *            Maven repository.
 * @param factory
 *            Factory used for creating artifacts.
 * @param metadataSource
 *            ArtifactMetadataSource provided by maven.
 * @param projectDescs
 *            list of maven project descriptors. Each descriptor contains
 *            MavenProject, a list of project's remote repositories and a
 *            boolean indicator if the project needs to be resolved
 *            transitively or not.
 * @return a dependency tree as a list of rootnodes (instances of
 *         DependencyNode class) which contain their own subtrees. Each
 *         rootnode corresponds to one maven project provided as argument.
 *         The order of rootnodes list is the same as order of provided
 *         maven projects list.
 * @throws DependencyTreeBuilderException
 *             Notifies about a problem during building the dependency tree.
 * @throws ArtifactMetadataRetrievalException
 *             Signals problem with metadata retieval.
 * @throws InvalidVersionSpecificationException
 *             Informs about invalid version specifications.
 * @throws NoSuchFieldException
 *             Exception related to reflection.
 * @throws SecurityException
 *             Exception thrown by security manager.
 * @throws IllegalAccessException
 *             Illegal access during usage of java reflection.
 * @throws IllegalArgumentException
 *             Illegal argument was passed.
 */
public List<RootNode> buildDependencyTree(final ArtifactRepository repository, final ArtifactFactory factory,
        final ArtifactMetadataSource metadataSource, final MavenProjectDescriptor... projectDescs)
        throws DependencyTreeBuilderException, ArtifactMetadataRetrievalException,
        InvalidVersionSpecificationException, SecurityException, NoSuchFieldException, IllegalArgumentException,
        IllegalAccessException {
    ArtifactFilter filter = new ScopeArtifactFilter();
    DependencyTreeResolutionListener listener = new DependencyTreeResolutionListener(filter);
    Map resolvedArtifacts = new LinkedHashMap();
    for (MavenProjectDescriptor projectDesc : projectDescs) {
        MavenProject project = projectDesc.project;
        try {
            List<String> separatedGroupId = extractSeparatedGroupIds(project);

            // Here you can simply add to create a new list
            List remoteRepositories = projectDesc.remoteRepositories;

            // If artifact is marked in pom as a bundle then it is changed
            // to jar. Retaining bundle can impose problems when the
            // artifact is duplicated or conflicted with other artifact
            // specified as a dependency, because in the
            // dependency there is only jar type specified.
            Artifact originatingArtifact = project.getArtifact();
            this.stringifiedRoot = FilteringVisitorSupport.stringify(originatingArtifact);
            if ("bundle".equals(originatingArtifact.getType())) {
                Artifact changeArtifact = artifactFactory.createArtifact(originatingArtifact.getGroupId(),
                        originatingArtifact.getArtifactId(), originatingArtifact.getVersion(),
                        originatingArtifact.getScope(), "jar");
                originatingArtifact = changeArtifact;
            }
            ResolutionNode root = new ResolutionNode(originatingArtifact, remoteRepositories);

            // If the project is not supposed to be transitively resolved
            // then its dependencies are not added to the root. Moreover the
            // parameter is passed to the recurse method. Thanks to than
            // when transitive is false, resolving of runtime dependencies
            // is not performed.
            if (projectDesc.transitive) {
                Set<Artifact> dependencyArtifacts = project.getDependencyArtifacts();

                if (dependencyArtifacts == null) {
                    dependencyArtifacts = new LinkedHashSet();
                    List dependencies = project.getDependencies();
                    for (Object depObj : dependencies) {
                        Dependency dep = (Dependency) depObj;
                        if (dep.isOptional()) {
                            // filtering optional dependencies
                            continue;
                        }
                        Artifact dependencyArtifact;
                        VersionRange versionRange = VersionRange.createFromVersionSpec(dep.getVersion());
                        dependencyArtifact = factory.createDependencyArtifact(dep.getGroupId(),
                                dep.getArtifactId(), versionRange, dep.getType(), dep.getClassifier(),
                                dep.getScope());
                        if (dep.getExclusions() != null) {
                            if (!dep.getExclusions().isEmpty()) {
                                List<String> patterns = new ArrayList<String>();
                                for (Exclusion exclusion : dep.getExclusions()) {
                                    patterns.add(exclusion.getGroupId() + ":" + exclusion.getArtifactId());
                                }
                                dependencyArtifact.setDependencyFilter(new ExcludesArtifactFilter(patterns));
                            }
                        }
                        dependencyArtifacts.add(dependencyArtifact);
                    }
                } else {
                    // filtering optional dependencies
                    Set<Artifact> filteredArtifacts = new LinkedHashSet();
                    for (Artifact a : dependencyArtifacts) {
                        if (!a.isOptional()) {
                            filteredArtifacts.add(a);
                        }
                    }
                    dependencyArtifacts = filteredArtifacts;
                }

                for (Artifact depArtifact : dependencyArtifacts) {
                    if (depArtifact.getVersion() != null) {
                        if (!depArtifact.getVersion().equals(depArtifact.getBaseVersion())) {
                            if (depArtifact.isSnapshot()) {
                                depArtifact.setVersion(depArtifact.getBaseVersion());
                            }
                        }
                    }
                }

                root.addDependencies(dependencyArtifacts, remoteRepositories, filter);
            }

            // Information about managed versions is extracted from the
            // artifact's pom (but also from parent poms and settings.xml
            // file).
            ManagedVersionMap versionMap = getManagedVersionsMap(originatingArtifact,
                    project.getManagedVersionMap());

            recurse(originatingArtifact, root, resolvedArtifacts, versionMap, localRepository,
                    remoteRepositories, metadataSource, filter, listener, projectDesc.transitive,
                    new HashSet<String>(separatedGroupId));
        } catch (ArtifactResolutionException exception) {
            throw new DependencyTreeBuilderException("Cannot build project dependency tree", exception);
        }
    }
    return listener.getRootNodes();
}