Package org.apache.maven.artifact.resolver

Examples of org.apache.maven.artifact.resolver.ArtifactResolutionResult


                                             Map managedVersions, ArtifactResolutionRequest repositoryRequest,
                                             ArtifactMetadataSource source, ArtifactFilter filter,
                                             List<ResolutionListener> listeners,
                                             List<ConflictResolver> conflictResolvers )
    {
        ArtifactResolutionResult result = new ArtifactResolutionResult();

        result.setOriginatingArtifact( originatingArtifact );

        if ( conflictResolvers == null )
        {
            conflictResolvers = Collections.singletonList( defaultConflictResolver );
        }

        Map<Object, List<ResolutionNode>> resolvedArtifacts = new LinkedHashMap<Object, List<ResolutionNode>>();

        ResolutionNode root = new ResolutionNode( originatingArtifact, repositoryRequest.getRemoteRepositories() );

        try
        {
            root.addDependencies( artifacts, repositoryRequest.getRemoteRepositories(), filter );
        }
        catch ( CyclicDependencyException e )
        {
            result.addCircularDependencyException( e );

            return result;
        }
        catch ( OverConstrainedVersionException e )
        {
            result.addVersionRangeViolation( e );

            return result;
        }

        ManagedVersionMap versionMap = getManagedVersionsMap( originatingArtifact, managedVersions );

        try
        {
            recurse( result, root, resolvedArtifacts, versionMap, repositoryRequest, source, filter, listeners,
                     conflictResolvers );
        }
        catch ( CyclicDependencyException e )
        {
            logger.debug( "While recursing: " + e.getMessage(), e );
            result.addCircularDependencyException( e );
        }
        catch ( OverConstrainedVersionException e )
        {
            logger.debug( "While recursing: " + e.getMessage(), e );
            result.addVersionRangeViolation( e );
        }
        catch ( ArtifactResolutionException e )
        {
            logger.debug( "While recursing: " + e.getMessage(), e );
            result.addErrorArtifactException( e );
        }

        Set<ResolutionNode> set = new LinkedHashSet<ResolutionNode>();

        for ( List<ResolutionNode> nodes : resolvedArtifacts.values() )
        {
            for ( ResolutionNode node : nodes )
            {
                if ( !node.equals( root ) && node.isActive() )
                {
                    Artifact artifact = node.getArtifact();

                    try
                    {
                        if ( node.filterTrail( filter ) )
                        {
                            // If it was optional and not a direct dependency,
                            // we don't add it or its children, just allow the update of the version and artifactScope
                            if ( node.isChildOfRootNode() || !artifact.isOptional() )
                            {
                                artifact.setDependencyTrail( node.getDependencyTrail() );

                                set.add( node );

                                // This is required right now.
                                result.addArtifact( artifact );
                            }
                        }
                    }
                    catch ( OverConstrainedVersionException e )
                    {
                        result.addVersionRangeViolation( e );
                    }
                }
            }
        }

        result.setArtifactResolutionNodes( set );

        return result;
    }
View Full Code Here


            try
            {
                artifact =
                    artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );

                ArtifactResolutionResult arr =
                    resolver.resolveTransitively( Collections.singleton( artifact ), originatingArtifact,
                                                  remoteRepositories, localRepository, artifactMetadataSource );

                if ( !groupId.equals( artifact.getGroupId() ) || !artifactId.equals( artifact.getArtifactId() )
                    || !version.equals( artifact.getVersion() ) )
                {
                    artifact =
                        artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
                    copyPoms( artifact, testRepository );
                }

                for ( Artifact arrArtifact : (Set<Artifact>) arr.getArtifacts() )
                {
                    copyArtifact( arrArtifact, testRepository );
                }
            }
            catch ( Exception e )
View Full Code Here

    private Set<Artifact> getFilteredResolvedArtifacts( MavenProject project, Set<Artifact> artifacts,
                                                        ArtifactFilter filter )
    {
        try
        {
            ArtifactResolutionResult result =
                resolver.resolveTransitively( artifacts, project.getArtifact(), localRepository, remoteRepositories,
                                              metadataSource, filter );

            @SuppressWarnings( "unchecked" )
            Set<Artifact> resolvedArtifacts = result.getArtifacts();

            return resolvedArtifacts;
        }
        catch ( ArtifactResolutionException e )
        {
View Full Code Here

            Artifact artifact = null;
            try
            {
                artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );

                ArtifactResolutionResult arr =
                    resolver.resolveTransitively( Collections.singleton( artifact ), originatingArtifact,
                                                  remoteRepositories, localRepository, artifactMetadataSource );

                if ( !groupId.equals( artifact.getGroupId() ) || !artifactId.equals( artifact.getArtifactId() )
                    || !version.equals( artifact.getVersion() ) )
                {
                    artifact =
                        artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, classifier );
                    copyPoms( artifact, testRepository );
                }

                for ( Artifact arrArtifact : (Set<Artifact>) arr.getArtifacts() )
                {
                    copyArtifact( arrArtifact, testRepository );
                }
            }
            catch ( Exception e )
View Full Code Here

                        classpathElements.addAll( getProjectBuildOutputDirs( subProject ) );

                        Set<Artifact> dependencyArtifacts = subProject.createArtifacts( factory, null, null );
                        if ( !dependencyArtifacts.isEmpty() )
                        {
                            ArtifactResolutionResult result = null;
                            try
                            {
                                result = resolver.resolveTransitively( dependencyArtifacts, subProject.getArtifact(),
                                                                       subProject.getManagedVersionMap(),
                                                                       localRepository,
View Full Code Here

            MavenProject artifactProject =
                mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository );
            Set<Artifact> dependencyArtifacts = artifactProject.createArtifacts( factory, null, null );
            if ( !dependencyArtifacts.isEmpty() )
            {
                ArtifactResolutionResult result =
                    resolver.resolveTransitively( dependencyArtifacts, artifactProject.getArtifact(),
                                                  artifactProject.getRemoteArtifactRepositories(), localRepository,
                                                  artifactMetadataSource );
                Set<Artifact> artifacts = result.getArtifacts();

                Map<String, Artifact> compileArtifactMap = new HashMap<String, Artifact>();
                populateCompileArtifactMap( compileArtifactMap, artifacts );

                for ( Artifact a : compileArtifactMap.values() )
View Full Code Here

                {
                    Map managedVersions =
                        createManagedVersionMap( getArtifactFactory(), project.getId(),
                                                 project.getDependencyManagement() );

                    ArtifactResolutionResult artifactResolutionResult = null;

                    try
                    {

                        List listeners = new ArrayList();

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

                        listeners.add( new WarningResolutionListener( logger ) );

                        artifactResolutionResult =
                            artifactCollector.collect( getProjectArtifacts(), project.getArtifact(), managedVersions,
                                                       localRepo, project.getRemoteArtifactRepositories(),
                                                       getArtifactMetadataSource(), null, listeners );
                    }
                    catch ( ArtifactResolutionException e )
                    {
                        getLog().debug( e.getMessage(), e );
                        getLog().error(
                                        Messages.getString( "AbstractIdeSupportMojo.artifactresolution", new Object[] { //$NON-NLS-1$
                                                            e.getGroupId(), e.getArtifactId(), e.getVersion(),
                                                                e.getMessage() } ) );

                        // if we are here artifactResolutionResult is null, create a project without dependencies but
                        // don't fail
                        // (this could be a reactor projects, we don't want to fail everything)
                        // Causes MECLIPSE-185. Not sure if it should be handled this way??
                        return new IdeDependency[0];
                    }

                    // keep track of added reactor projects in order to avoid duplicates
                    Set emittedReactorProjectId = new HashSet();

                    for ( Iterator i = artifactResolutionResult.getArtifactResolutionNodes().iterator(); i.hasNext(); )
                    {

                        ResolutionNode node = (ResolutionNode) i.next();
                        int dependencyDepth = node.getDepth();
                        Artifact art = node.getArtifact();
View Full Code Here

            // not forgetting the Artifact of the project itself
            dependencyArtifacts.add(executableProject.getArtifact());

            // resolve all dependencies transitively to obtain a comprehensive
            // list of assemblies
            ArtifactResolutionResult result = artifactResolver.resolveTransitively(dependencyArtifacts,
                                                                                   executablePomArtifact,
                                                                                   Collections.EMPTY_MAP,
                                                                                   this.localRepository,
                                                                                   this.remoteRepositories,
                                                                                   metadataSource, null,
                                                                                   Collections.EMPTY_LIST);
            executableDependencies = result.getArtifacts();

        } catch (Exception ex) {
            throw new MojoExecutionException("Encountered problems resolving dependencies of the executable "
                                             + "in preparation for its execution.", ex);
        }
View Full Code Here

        if ( actTransitively )
        {
            try
            {
                ArtifactResolutionResult result;

                if ( snapshotsOnly )
                {
                    result = resolver.resolveTransitively( dependencyArtifacts, project.getArtifact(), localRepository,
                                                           remoteRepositories, source, new ArtifactFilter()
                    {
                        public boolean include( Artifact artifact )
                        {
                            return artifact.isSnapshot();
                        }
                    } );
                }
                else
                {
                    result =
                        resolver.resolveTransitively( dependencyArtifacts, project.getArtifact(), remoteRepositories,
                                                      localRepository, source );
                }

                artifactMap = ArtifactUtils.artifactMapByVersionlessId( result.getArtifacts() );
            }
            catch ( ArtifactResolutionException e )
            {
                verbose( "Skipping: " + e.getArtifactId() + ". It cannot be resolved." );
            }
View Full Code Here

    public void execute()
        throws MojoExecutionException
  {
    try
    {
            ArtifactResolutionResult result =
                this.artifactCollector.collect( project.getArtifacts(), project.getArtifact(), this.getLocal(),
                                                this.remoteRepos, this.artifactMetadataSource,
                                                new ScopeArtifactFilter( Artifact.SCOPE_TEST ), new ArrayList() );
      Set repos = new HashSet();
      Set<ResolutionNode> nodes = result.getArtifactResolutionNodes();
            for ( ResolutionNode node : nodes )
      {
                repos.addAll( node.getRemoteRepositories() );
      }
View Full Code Here

TOP

Related Classes of org.apache.maven.artifact.resolver.ArtifactResolutionResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.