• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultDependencyResolutionRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.maven.project.DefaultDependencyResolutionRequest的典型用法代码示例。如果您正苦于以下问题:Java DefaultDependencyResolutionRequest类的具体用法?Java DefaultDependencyResolutionRequest怎么用?Java DefaultDependencyResolutionRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DefaultDependencyResolutionRequest类属于org.apache.maven.project包,在下文中一共展示了DefaultDependencyResolutionRequest类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getBundleDependencies

import org.apache.maven.project.DefaultDependencyResolutionRequest; //导入依赖的package包/类
public Set<BundleArtifact> getBundleDependencies(String... scopes)
		throws MojoExecutionException {
	ScopeDependencyFilter scopeFilter = new ScopeDependencyFilter(Arrays.asList(scopes), null);

	DefaultDependencyResolutionRequest dependencyResolutionRequest = new DefaultDependencyResolutionRequest(
			project, repositorySystemSession);
	dependencyResolutionRequest.setResolutionFilter(scopeFilter);

	DependencyResolutionResult dependencyResolutionResult;
	try {
		dependencyResolutionResult = projectDependenciesResolver
				.resolve(dependencyResolutionRequest);
	} catch (DependencyResolutionException ex) {
		throw new MojoExecutionException(ex.getMessage(), ex);
	}

	DependencyNode dependencyGraph = dependencyResolutionResult.getDependencyGraph();
	if (dependencyGraph != null) {
		checkBundleDependencies(dependencyGraph.getChildren());
		return getBundleArtifacts(dependencyGraph.getChildren());
	} else {
		return new HashSet<BundleArtifact>();
	}
}
 
开发者ID:apache,项目名称:incubator-taverna-osgi,代码行数:25,代码来源:MavenOsgiUtils.java


示例2: resolveDependencies

import org.apache.maven.project.DefaultDependencyResolutionRequest; //导入依赖的package包/类
protected void resolveDependencies() throws MojoExecutionException {
    DependencyResolutionResult depRes;
    try {
        DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(mavenSession.getRepositorySession());
        ((DefaultRepositorySystemSession)repositorySession).setDependencySelector(newRootScopeDependencySelector(repositorySession.getDependencySelector(), 0));
        DefaultDependencyResolutionRequest depReq = new DefaultDependencyResolutionRequest(project, repositorySession);
        depRes = depsResolver.resolve(depReq);
    } catch (DependencyResolutionException e) {
        throw new MojoExecutionException("Cannot resolve dependencies for "+project, e);
    }
    rootDependencyGraph = depRes.getDependencyGraph();
    getLog().debug("Dependency graph with scopes "+includeDependencyScopes+":");
    dump("", rootDependencyGraph);

    projectByIdCache.put(Coords.of(project).normal(), project);
    collectDeps(rootDependencyGraph, project, 0);
}
 
开发者ID:ahgittin,项目名称:license-audit-maven-plugin,代码行数:18,代码来源:AbstractLicensingMojo.java


示例3: execute

import org.apache.maven.project.DefaultDependencyResolutionRequest; //导入依赖的package包/类
@Override
protected void execute(GitBranchType type, String gitBranch, String branchPattern) throws MojoExecutionException, MojoFailureException {
    getLog().debug("update-stage-dependencies setting up Repository session...");

    DefaultRepositorySystemSession reresolveSession = new DefaultRepositorySystemSession(session);
    reresolveSession.setUpdatePolicy(org.eclipse.aether.repository.RepositoryPolicy.UPDATE_POLICY_ALWAYS);
    reresolveSession.setCache(new DefaultRepositoryCache());

    LocalRepositoryManager localRepositoryManager = reresolveSession.getLocalRepositoryManager();

    getLog().debug("configuring stage as the remote repository for artifact resolution requests...");
    List<RemoteRepository> stageRepo = Arrays.asList(getRepository(stageDeploymentRepository));

    boolean itemsPurged = false;

    try {
        DependencyResolutionResult depencencyResult = dependenciesResolver.resolve(
                new DefaultDependencyResolutionRequest(project, reresolveSession));

        for (Dependency dependency : depencencyResult.getResolvedDependencies()) {
            if (!dependency.getArtifact().isSnapshot()) {
                // Find the artifact in the local repo, and if it came from the 'stageRepo', populate that info
                // as the 'repository' on the artifact.
                LocalArtifactResult localResult = localRepositoryManager.find(reresolveSession,
                        new LocalArtifactRequest(dependency.getArtifact(), stageRepo, null));

                // If the result has a file... and the getRepository() matched the stage repo id...
                if (localResult.getFile() != null && localResult.getRepository() != null) {
                    getLog().info("Purging: " + dependency + " from remote repository: " + localResult.getRepository() + ".");
                    File deleteTarget = new File(localRepositoryManager.getRepository().getBasedir(), localRepositoryManager.getPathForLocalArtifact(dependency.getArtifact()));

                    if (deleteTarget.isDirectory()) {
                        try {
                            FileUtils.deleteDirectory(deleteTarget);
                        } catch (IOException ioe) {
                            getLog().warn("Failed to purge stage artifact from local repository: " + deleteTarget, ioe);
                        }
                    } else if (!deleteTarget.delete()) {
                        getLog().warn("Failed to purge stage artifact from local repository: " + deleteTarget);
                    }
                    itemsPurged = true;
                }
            }
        }
    } catch (DependencyResolutionException dre) {
        throw new MojoExecutionException("Initial dependency resolution to resolve dependencies which may have been provided by the 'stage' repository failed.", dre);
    }


    if (itemsPurged) {
        try {
            getLog().info("Resolving purged dependencies...");
            dependenciesResolver.resolve(new DefaultDependencyResolutionRequest(project, reresolveSession));
            getLog().info("All stage dependencies purged and re-resolved.");
        } catch (DependencyResolutionException e) {
            throw new MojoExecutionException("Post-purge dependency resolution failed!", e);
        }
    }
}
 
开发者ID:egineering-llc,项目名称:gitflow-helper-maven-plugin,代码行数:60,代码来源:UpdateStageDependenciesMojo.java


示例4: getDependencies

import org.apache.maven.project.DefaultDependencyResolutionRequest; //导入依赖的package包/类
private Set<Artifact> getDependencies( MavenProject project, Collection<String> scopesToCollect,
                                       Collection<String> scopesToResolve, MavenSession session,
                                       boolean aggregating, Set<Artifact> projectArtifacts )
    throws LifecycleExecutionException
{
    if ( scopesToCollect == null )
    {
        scopesToCollect = Collections.emptySet();
    }
    if ( scopesToResolve == null )
    {
        scopesToResolve = Collections.emptySet();
    }

    if ( scopesToCollect.isEmpty() && scopesToResolve.isEmpty() )
    {
        return new LinkedHashSet<Artifact>();
    }

    scopesToCollect = new HashSet<String>( scopesToCollect );
    scopesToCollect.addAll( scopesToResolve );

    DependencyFilter collectionFilter = new ScopeDependencyFilter( null, negate( scopesToCollect ) );
    DependencyFilter resolutionFilter = new ScopeDependencyFilter( null, negate( scopesToResolve ) );
    resolutionFilter = AndDependencyFilter.newInstance( collectionFilter, resolutionFilter );
    resolutionFilter =
        AndDependencyFilter.newInstance( resolutionFilter, new ReactorDependencyFilter( projectArtifacts ) );

    DependencyResolutionResult result;
    try
    {
        DefaultDependencyResolutionRequest request =
            new DefaultDependencyResolutionRequest( project, session.getRepositorySession() );
        request.setResolutionFilter( resolutionFilter );

        eventSpyDispatcher.onEvent( request );

        result = dependenciesResolver.resolve( request );
    }
    catch ( DependencyResolutionException e )
    {
        result = e.getResult();

        /*
         * MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator
         * plugins that require dependency resolution although they usually run in phases of the build where project
         * artifacts haven't been assembled yet. The prime example of this is "mvn release:prepare".
         */
        if ( aggregating && areAllDependenciesInReactor( session.getProjects(), result.getUnresolvedDependencies() ) )
        {
            logger.warn( "The following dependencies could not be resolved at this point of the build"
                + " but seem to be part of the reactor:" );

            for ( Dependency dependency : result.getUnresolvedDependencies() )
            {
                logger.warn( "o " + dependency );
            }

            logger.warn( "Try running the build up to the lifecycle phase \"package\"" );
        }
        else
        {
            throw new LifecycleExecutionException( null, project, e );
        }
    }

    eventSpyDispatcher.onEvent( result );

    Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
    if ( result.getDependencyGraph() != null && !result.getDependencyGraph().getChildren().isEmpty() )
    {
        RepositoryUtils.toArtifacts( artifacts, result.getDependencyGraph().getChildren(),
                                     Collections.singletonList( project.getArtifact().getId() ), collectionFilter );
    }
    return artifacts;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:77,代码来源:LifecycleDependencyResolver.java



注:本文中的org.apache.maven.project.DefaultDependencyResolutionRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SqlMapClientCallback类代码示例发布时间:2022-05-23
下一篇:
Java State类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap