Resolves dependencies transitively from the given jar artifact, with the specified Maven scope
(compile, runtime, and so on.)
349456
public DependencyResult resolveDependencies(GAV a, String scope) throws DependencyResolutionException {
        DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(scope);

        CollectRequest collectRequest = new CollectRequest();
        collectRequest.setRoot(new Dependency(new DefaultArtifact(a.toString()), JavaScopes.COMPILE));
        collectRequest.setRepositories(remoteRepositories);

        DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFlter);

        return resolveDependencies(dependencyRequest);
    }
674019
public void addDependency(String notation, String scope ) {
        Map<String, String> notationMap = Notation.parse(notation);
        Dependency dependency = new Dependency();
        dependency.setGroupId(notationMap.get("groupId"));
        dependency.setArtifactId(notationMap.get("artifactId"));
        dependency.setType(notationMap.get("type"));
        dependency.setVersion(notationMap.get("version"));
        dependency.setScope( scope );
        addDependency(dependency);
    }
454814
public Set<Artifact> resolve(String groupId, String artifactId) throws MojoExecutionException {
		final ArtifactResolutionRequest request = new ArtifactResolutionRequest();
		request.setResolveRoot(true);
		request.setResolveTransitively(true);
		request.setLocalRepository(getSession().getLocalRepository());
		request.setRemoteRepositories(getSession().getCurrentProject().getRemoteArtifactRepositories());
		request.setOffline(getSession().isOffline());
		request.setForceUpdate(getSession().getRequest().isUpdateSnapshots());
		request.setServers(getSession().getRequest().getServers());
		request.setMirrors(getSession().getRequest().getMirrors());
		request.setProxies(getSession().getRequest().getProxies());
		request.setArtifact(createArtifact(groupId, artifactId));

		final ArtifactResolutionResult result = resolve(request);

		return result.getArtifacts();
	}
737575
def resolve_dependencies(main, version)
      dependencies = @identifier.identify(main.source.fetch(version))
      artifact = @graph.artifact main.name, version

      dependencies.each do |dependency|
        dependency.constraints.each do |constraint|
          artifact.depends dependency.name, constraint
        end

        resolve_dependency dependency
      end

      nil
    end
128513
private List<Artifact> getScopeArtifacts( final MavenProject project, final String scope )
    {
        if ( SCOPE_COMPILE.equals( scope ) )
        {
            return project.getCompileArtifacts();
        }
        if ( SCOPE_RUNTIME.equals( scope ) )
        {
            return project.getRuntimeArtifacts();
        }
        else if ( SCOPE_TEST.equals( scope ) )
        {
            return project.getTestArtifacts();
        }
        else
        {
            throw new RuntimeException( "Not allowed scope " + scope );
        }
    }
1181489
def resolve_dependency(dependency)
      @dependencies[dependency.name] ||= dependency

      dependency
        .source
        .versions(
          dependency.constraints,
          @identifier.initial_elm_version,
          !@options[:skip_update],
          @options[:only_update]
        )
        .each do |version|
          next if @graph.artifact?(dependency.name, version)
          resolve_dependencies(dependency, version)
        end

      nil
    end
569630
@SuppressWarnings("unchecked")
    protected void addRelevantProjectDependencies(Set<Artifact> artifacts) throws Exception {
        getLog().debug("Project Dependencies will be included.");

        Set<Artifact> dependencies = project.getArtifacts();
        getLog().debug("There are " + dependencies.size() + " dependencies in the project");

        // system scope dependencies are not returned by maven 2.0. See MEXEC-17
        dependencies.addAll(getAllNonTestOrProvidedScopedDependencies());

        Iterator<Artifact> iter = dependencies.iterator();
        while (iter.hasNext()) {
            Artifact classPathElement = iter.next();
            getLog().debug("Adding project dependency artifact: " + classPathElement.getArtifactId() + " to classpath");

            artifacts.add(classPathElement);
        }
    }
1353029
public void execute( EnforcerRuleHelper helper )
        throws EnforcerRuleException
    {

        // get the project
        MavenProject project = null;
        try
        {
            project = (MavenProject) helper.evaluate( "${project}" );
        }
        catch ( ExpressionEvaluationException eee )
        {
            throw new EnforcerRuleException( "Unable to retrieve the MavenProject: ", eee );
        }

        try
        {
            graphBuilder = (DependencyGraphBuilder) helper.getComponent( DependencyGraphBuilder.class );
        }
        catch ( ComponentLookupException e )
        {
            // real cause is probably that one of the Maven3 graph builder could not be initiated and fails with a ClassNotFoundException
            try
            {
                graphBuilder = (DependencyGraphBuilder) helper.getComponent( DependencyGraphBuilder.class.getName(), "maven2" );
            }
            catch ( ComponentLookupException e1 )
            {
                throw new EnforcerRuleException( "Unable to lookup DependencyGraphBuilder: ", e );
            }
        }
        
        // get the correct list of dependencies
        Set<Artifact> dependencies = getDependenciesToCheck( project );

        // look for banned dependencies
        Set<Artifact> foundExcludes = checkDependencies( dependencies, helper.getLog() );

        // if any are found, fail the check but list all of them
        if ( foundExcludes != null && !foundExcludes.isEmpty() )
        {
            String message = getMessage();
            
            StringBuilder buf = new StringBuilder();
            if ( message != null )
            {
                buf.append( message + "\n" );
            }
            for ( Artifact artifact : foundExcludes )
            {
                buf.append( getErrorMessage( artifact ) );
            }
            message = buf.toString() + "Use 'mvn dependency:tree' to locate the source of the banned dependencies.";

            throw new EnforcerRuleException( message );
        }

    }
1044774
private void resolveDependencies(final Object reference) {
        final Class<?> superclass = reference.getClass().getSuperclass().getSuperclass(); // Proxy -> Orig -> Super

        resolveSuperclassFieldDependencies(reference, superclass);
        resolveCurrentclassFieldDependencies(reference);
    }
372049
public MavenProject getMavenProject(Artifact artifact) {
		try {
			final MavenSession session = getMavenSession();
			final MavenProject current = session.getCurrentProject();
			final MavenProject prj = getMavenProjectBuilder().buildFromRepository(
					artifact,
					current.getRemoteArtifactRepositories(),
					session.getLocalRepository());
			return prj;
		} catch (ProjectBuildingException e) {
			getLog().warn(e);
		}
		return null;
	}
1133646
public static Dependency createDependency(final Artifact artifact, final String scope) throws UnsupportedScopeException{
        try{
            final Scope depScope = Scope.valueOf(scope.toUpperCase());
            return createDependency(artifact, depScope);
        }
        catch(IllegalArgumentException e){
			LOG.log(Level.SEVERE, String.format("Cannot identify scope for string %s. Details: %s", scope, e.getMessage()), e);
            throw new UnsupportedScopeException();
        }
	}
277505
public ModelSource resolveModel( Parent parent )
            throws UnresolvableModelException {

        Dependency parentDependency = new Dependency();
        parentDependency.setGroupId(parent.getGroupId());
        parentDependency.setArtifactId(parent.getArtifactId());
        parentDependency.setVersion(parent.getVersion());
        parentDependency.setClassifier("");
        parentDependency.setType("pom");

        Artifact parentArtifact = null;
        try
        {
            Iterable<ArtifactResult> artifactResults = depencencyResolver.resolveDependencies(
                    projectBuildingRequest, singleton(parentDependency), null, null );
            Iterator<ArtifactResult> iterator = artifactResults.iterator();
            if (iterator.hasNext()) {
                parentArtifact = iterator.next().getArtifact();
            }
        } catch (DependencyResolverException e) {
            throw new UnresolvableModelException( e.getMessage(), parent.getGroupId(), parent.getArtifactId(),
                    parent.getVersion(), e );
        }

        return resolveModel( parentArtifact.getGroupId(), parentArtifact.getArtifactId(), parentArtifact.getVersion() );
    }
255459
def resolve(spec, partial_manifests = [])
      manifests = implementation(spec).resolve(partial_manifests)
      manifests or return
      enforce_consistency!(spec.dependencies, manifests)
      enforce_acyclicity!(manifests) unless cyclic
      manifests = sort(manifests)
      Resolution.new(spec.dependencies, manifests)
    end
1240143
public CompilationUnitDeclaration resolve(
            ICompilationUnit sourceUnit,
            boolean verifyMethods,
            boolean analyzeCode,
            boolean generateCode) {

        return resolve(
            null,
            sourceUnit,
            verifyMethods,
            analyzeCode,
            generateCode);
    }
94600
private List<Resource> getResources( final MavenProject project, final String scope )
    {
        if ( SCOPE_COMPILE.equals( scope ) || SCOPE_RUNTIME.equals( scope ) )
        {
            return project.getResources();
        }
        else if ( SCOPE_TEST.equals( scope ) )
        {
            List<Resource> resources = new ArrayList<Resource>();
            resources.addAll( project.getTestResources() );
            resources.addAll( project.getResources() );
            return resources;
        }
        else
        {
            throw new RuntimeException( "Not allowed scope " + scope );
        }
    }
860507
protected Plugin resolvePlugin( Plugin plugin, MavenProject project )
    {

        @SuppressWarnings( "unchecked" )
        List<ArtifactRepository> pluginRepositories = project.getPluginArtifactRepositories();
        Artifact artifact =
            factory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(),
                                          VersionRange.createFromVersion( "LATEST" ) );

        try
        {
            this.resolver.resolve( artifact, pluginRepositories, this.local );
            plugin.setVersion( artifact.getVersion() );
        }
        catch ( ArtifactResolutionException e )
        {
        }
        catch ( ArtifactNotFoundException e )
        {
        }

        return plugin;
    }
323656
private void reduceDependencies(Map<ResolvedFolder, AbstractDependencyResolver> topFolderResolverMap) {
        //reduce the dependencies and duplicates files
        Set<String> topFolders = new HashSet<>();
        topFolderResolverMap.entrySet().forEach((resolverEntry) -> topFolders.addAll(resolverEntry.getKey().getTopFoldersFound().keySet()));

        // Take all resolvers and their folders
        for (Map.Entry<ResolvedFolder, AbstractDependencyResolver> entry : topFolderResolverMap.entrySet()) {
            AbstractDependencyResolver resolver = entry.getValue();
            ResolvedFolder resolvedFolder = entry.getKey();
            if (resolver != null && resolvedFolder != null) {
                // All folders of the current resolver (top folders and sub folders)
                Set<String> foldersFound = resolvedFolder.getTopFoldersFound().keySet();
                // Get the relevant folders for the current resolver (can be all folders or top folders only ...)
                Collection<String> foldersForResolver = resolver.getRelevantScannedFolders(foldersFound);
                // Remove all the irrelevant folders
                resolvedFolder.getTopFoldersFound().keySet().removeIf(folder -> !foldersForResolver.contains(folder));
            }
        }

    }