Package org.sonatype.aether.resolution

Examples of org.sonatype.aether.resolution.VersionResult


        {
            try
            {
                VersionRequest versionRequest =
                    new VersionRequest( artifact, request.getRepositories(), request.getRequestContext() );
                VersionResult versionResult = versionResolver.resolveVersion( session, versionRequest );

                artifact = artifact.setVersion( versionResult.getVersion() );
            }
            catch ( VersionResolutionException e )
            {
                result.addException( e );
                throw new ArtifactDescriptorException( result );
View Full Code Here


        String version = artifact.getVersion();
        if (!LATEST.equals(version))
            return delegate.resolveVersion(session,request);

        RequestTrace trace = DefaultRequestTrace.newChild(request.getTrace(), request);
        VersionResult result = new VersionResult( request );

        Metadata metadata =
            new DefaultMetadata( artifact.getGroupId(), artifact.getArtifactId(), MAVEN_METADATA_XML,
                                 Metadata.Nature.RELEASE_OR_SNAPSHOT );

        List<MetadataRequest> metadataRequests = new ArrayList<MetadataRequest>(request.getRepositories().size());

        metadataRequests.add( new MetadataRequest( metadata, null, request.getRequestContext() ) );

        for ( RemoteRepository repository : request.getRepositories() )
        {
            MetadataRequest metadataRequest =
                new MetadataRequest( metadata, repository, request.getRequestContext() );
            metadataRequest.setDeleteLocalCopyIfMissing( true );
            metadataRequest.setFavorLocalRepository( true );
            metadataRequest.setTrace( trace );
            metadataRequests.add( metadataRequest );
        }

        List<MetadataResult> metadataResults = metadataResolver.resolveMetadata( session, metadataRequests );

        List<VersionInfo> infos = new ArrayList<VersionInfo>();

        for (MetadataResult metadataResult : metadataResults) {
            result.addException(metadataResult.getException());

            ArtifactRepository repository = metadataResult.getRequest().getRepository();
            if (repository == null) {
                repository = session.getLocalRepository();
            }

            Versioning versioning = readVersions(session, trace, metadataResult.getMetadata(), repository, result);
            merge(versioning, repository, infos);
        }

        VersionInfo latest = findLatest(infos);
        if (latest!=null) {
            result.setRepository(latest.repository);
            result.setVersion(latest.version.toString());
        }

        if (latest != null && latest.version.toString().endsWith(SNAPSHOT)) {
            VersionRequest subRequest = new VersionRequest();
            subRequest.setArtifact(artifact.setVersion(result.getVersion()));
            if (result.getRepository() instanceof RemoteRepository) {
                subRequest.setRepositories(Collections.singletonList((RemoteRepository) result.getRepository()));
            } else {
                subRequest.setRepositories(request.getRepositories());
            }
            VersionResult subResult = resolveVersion(session, subRequest);
            result.setVersion(subResult.getVersion());
            result.setRepository(subResult.getRepository());
            for (Exception exception : subResult.getExceptions()) {
                result.addException(exception);
            }
        }

        if ( StringUtils.isEmpty(result.getVersion()) )
View Full Code Here

                    artifactResolved( session, trace, artifact, null, result.getExceptions() );
                }
                continue;
            }

            VersionResult versionResult;
            try
            {
                VersionRequest versionRequest = new VersionRequest( artifact, repos, request.getRequestContext() );
                versionRequest.setTrace( trace );
                versionResult = versionResolver.resolveVersion( session, versionRequest );
            }
            catch ( VersionResolutionException e )
            {
                result.addException( e );
                continue;
            }

            artifact = artifact.setVersion( versionResult.getVersion() );

            if ( versionResult.getRepository() != null )
            {
                if ( versionResult.getRepository() instanceof RemoteRepository )
                {
                    repos = Collections.singletonList( (RemoteRepository) versionResult.getRepository() );
                }
                else
                {
                    repos = Collections.emptyList();
                }
            }

            if ( workspace != null )
            {
                File file = workspace.findArtifact( artifact );
                if ( file != null )
                {
                    artifact = artifact.setFile( file );
                    result.setArtifact( artifact );
                    result.setRepository( workspace.getRepository() );
                    artifactResolved( session, trace, artifact, result.getRepository(), null );
                    continue;
                }
            }

            LocalArtifactResult local =
                lrm.find( session, new LocalArtifactRequest( artifact, repos, request.getRequestContext() ) );
            if ( local.isAvailable()
                || ( local.getFile() != null && versionResult.getRepository() instanceof LocalRepository ) )
            {
                if ( local.getRepository() != null )
                {
                    result.setRepository( local.getRepository() );
                }
View Full Code Here

TOP

Related Classes of org.sonatype.aether.resolution.VersionResult

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.