当前位置: 首页>>代码示例>>Java>>正文


Java RepositoryUtils.toArtifacts方法代码示例

本文整理汇总了Java中org.apache.maven.RepositoryUtils.toArtifacts方法的典型用法代码示例。如果您正苦于以下问题:Java RepositoryUtils.toArtifacts方法的具体用法?Java RepositoryUtils.toArtifacts怎么用?Java RepositoryUtils.toArtifacts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.RepositoryUtils的用法示例。


在下文中一共展示了RepositoryUtils.toArtifacts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolveDependencies

import org.apache.maven.RepositoryUtils; //导入方法依赖的package包/类
private DependencyResolutionResult resolveDependencies( MavenProject project, RepositorySystemSession session )
{
    DependencyResolutionResult resolutionResult = null;

    try
    {
        DefaultDependencyResolutionRequest resolution = new DefaultDependencyResolutionRequest( project, session );
        resolutionResult = dependencyResolver.resolve( resolution );
    }
    catch ( DependencyResolutionException e )
    {
        resolutionResult = e.getResult();
    }

    Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
    if ( resolutionResult.getDependencyGraph() != null )
    {
        RepositoryUtils.toArtifacts( artifacts, resolutionResult.getDependencyGraph().getChildren(),
                                     Collections.singletonList( project.getArtifact().getId() ), null );

        // Maven 2.x quirk: an artifact always points at the local repo, regardless whether resolved or not
        LocalRepositoryManager lrm = session.getLocalRepositoryManager();
        for ( Artifact artifact : artifacts )
        {
            if ( !artifact.isResolved() )
            {
                String path = lrm.getPathForLocalArtifact( RepositoryUtils.toArtifact( artifact ) );
                artifact.setFile( new File( lrm.getRepository().getBasedir(), path ) );
            }
        }
    }
    project.setResolvedArtifacts( artifacts );
    project.setArtifacts( artifacts );

    return resolutionResult;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:37,代码来源:DefaultProjectBuilder.java

示例2: getDependencies

import org.apache.maven.RepositoryUtils; //导入方法依赖的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.RepositoryUtils.toArtifacts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。