Search in sources :

Example 56 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultDependencyCollector method collectDependencies.

public CollectResult collectDependencies(RepositorySystemSession session, CollectRequest request) throws DependencyCollectionException {
    session = optimizeSession(session);
    RequestTrace trace = DefaultRequestTrace.newChild(request.getTrace(), request);
    CollectResult result = new CollectResult(request);
    DependencySelector depSelector = session.getDependencySelector();
    DependencyManager depManager = session.getDependencyManager();
    DependencyTraverser depTraverser = session.getDependencyTraverser();
    Dependency root = request.getRoot();
    List<RemoteRepository> repositories = request.getRepositories();
    List<Dependency> dependencies = request.getDependencies();
    List<Dependency> managedDependencies = request.getManagedDependencies();
    GraphEdge edge = null;
    if (root != null) {
        VersionRangeResult rangeResult;
        try {
            VersionRangeRequest rangeRequest = new VersionRangeRequest(root.getArtifact(), request.getRepositories(), request.getRequestContext());
            rangeRequest.setTrace(trace);
            rangeResult = versionRangeResolver.resolveVersionRange(session, rangeRequest);
            if (rangeResult.getVersions().isEmpty()) {
                throw new VersionRangeResolutionException(rangeResult, "No versions available for " + root.getArtifact() + " within specified range");
            }
        } catch (VersionRangeResolutionException e) {
            result.addException(e);
            throw new DependencyCollectionException(result);
        }
        Version version = rangeResult.getVersions().get(rangeResult.getVersions().size() - 1);
        root = root.setArtifact(root.getArtifact().setVersion(version.toString()));
        ArtifactDescriptorResult descriptorResult;
        try {
            ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
            descriptorRequest.setArtifact(root.getArtifact());
            descriptorRequest.setRepositories(request.getRepositories());
            descriptorRequest.setRequestContext(request.getRequestContext());
            descriptorRequest.setTrace(trace);
            if (isLackingDescriptor(root.getArtifact())) {
                descriptorResult = new ArtifactDescriptorResult(descriptorRequest);
            } else {
                descriptorResult = descriptorReader.readArtifactDescriptor(session, descriptorRequest);
            }
        } catch (ArtifactDescriptorException e) {
            result.addException(e);
            throw new DependencyCollectionException(result);
        }
        root = root.setArtifact(descriptorResult.getArtifact());
        repositories = remoteRepositoryManager.aggregateRepositories(session, repositories, descriptorResult.getRepositories(), true);
        dependencies = mergeDeps(dependencies, descriptorResult.getDependencies());
        managedDependencies = mergeDeps(managedDependencies, descriptorResult.getManagedDependencies());
        GraphNode node = new GraphNode();
        node.setAliases(descriptorResult.getAliases());
        node.setRepositories(request.getRepositories());
        edge = new GraphEdge(node);
        edge.setDependency(root);
        edge.setRequestContext(request.getRequestContext());
        edge.setRelocations(descriptorResult.getRelocations());
        edge.setVersionConstraint(rangeResult.getVersionConstraint());
        edge.setVersion(version);
    } else {
        edge = new GraphEdge(new GraphNode());
    }
    result.setRoot(edge);
    boolean traverse = (root == null) || depTraverser.traverseDependency(root);
    if (traverse && !dependencies.isEmpty()) {
        DataPool pool = new DataPool(session);
        EdgeStack edges = new EdgeStack();
        edges.push(edge);
        DefaultDependencyCollectionContext context = new DefaultDependencyCollectionContext(session, root, managedDependencies);
        Args args = new Args(result, session, trace, pool, edges, context);
        process(args, dependencies, repositories, depSelector.deriveChildSelector(context), depManager.deriveChildManager(context), depTraverser.deriveChildTraverser(context));
    }
    DependencyGraphTransformer transformer = session.getDependencyGraphTransformer();
    try {
        DefaultDependencyGraphTransformationContext context = new DefaultDependencyGraphTransformationContext(session);
        result.setRoot(transformer.transformGraph(edge, context));
    } catch (RepositoryException e) {
        result.addException(e);
    }
    if (!result.getExceptions().isEmpty()) {
        throw new DependencyCollectionException(result);
    }
    return result;
}
Also used : DependencyManager(org.sonatype.aether.collection.DependencyManager) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) RequestTrace(org.sonatype.aether.RequestTrace) DefaultRequestTrace(org.sonatype.aether.util.DefaultRequestTrace) DependencyTraverser(org.sonatype.aether.collection.DependencyTraverser) Version(org.sonatype.aether.version.Version) DependencyGraphTransformer(org.sonatype.aether.collection.DependencyGraphTransformer) VersionRangeRequest(org.sonatype.aether.resolution.VersionRangeRequest) ArtifactDescriptorRequest(org.sonatype.aether.resolution.ArtifactDescriptorRequest) VersionRangeResolutionException(org.sonatype.aether.resolution.VersionRangeResolutionException) DependencyCollectionException(org.sonatype.aether.collection.DependencyCollectionException) VersionRangeResult(org.sonatype.aether.resolution.VersionRangeResult) CollectResult(org.sonatype.aether.collection.CollectResult) RepositoryException(org.sonatype.aether.RepositoryException) Dependency(org.sonatype.aether.graph.Dependency) DependencySelector(org.sonatype.aether.collection.DependencySelector) ArtifactDescriptorResult(org.sonatype.aether.resolution.ArtifactDescriptorResult) ArtifactDescriptorException(org.sonatype.aether.resolution.ArtifactDescriptorException)

Example 57 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultDependencyCollector method process.

private void process(final Args args, List<Dependency> dependencies, List<RemoteRepository> repositories, DependencySelector depSelector, DependencyManager depManager, DependencyTraverser depTraverser) throws DependencyCollectionException {
    nextDependency: for (Dependency dependency : dependencies) {
        boolean disableVersionManagement = false;
        List<Artifact> relocations = Collections.emptyList();
        thisDependency: while (true) {
            if (!depSelector.selectDependency(dependency)) {
                continue nextDependency;
            }
            DependencyManagement depMngt = depManager.manageDependency(dependency);
            String premanagedVersion = null;
            String premanagedScope = null;
            if (depMngt != null) {
                if (depMngt.getVersion() != null && !disableVersionManagement) {
                    Artifact artifact = dependency.getArtifact();
                    premanagedVersion = artifact.getVersion();
                    dependency = dependency.setArtifact(artifact.setVersion(depMngt.getVersion()));
                }
                if (depMngt.getProperties() != null) {
                    Artifact artifact = dependency.getArtifact();
                    dependency = dependency.setArtifact(artifact.setProperties(depMngt.getProperties()));
                }
                if (depMngt.getScope() != null) {
                    premanagedScope = dependency.getScope();
                    dependency = dependency.setScope(depMngt.getScope());
                }
                if (depMngt.getExclusions() != null) {
                    dependency = dependency.setExclusions(depMngt.getExclusions());
                }
            }
            disableVersionManagement = false;
            boolean noDescriptor = isLackingDescriptor(dependency.getArtifact());
            boolean traverse = !noDescriptor && depTraverser.traverseDependency(dependency);
            VersionRangeResult rangeResult;
            try {
                VersionRangeRequest rangeRequest = new VersionRangeRequest();
                rangeRequest.setArtifact(dependency.getArtifact());
                rangeRequest.setRepositories(repositories);
                rangeRequest.setRequestContext(args.result.getRequest().getRequestContext());
                rangeRequest.setTrace(args.trace);
                Object key = args.pool.toKey(rangeRequest);
                rangeResult = args.pool.getConstraint(key, rangeRequest);
                if (rangeResult == null) {
                    rangeResult = versionRangeResolver.resolveVersionRange(args.session, rangeRequest);
                    args.pool.putConstraint(key, rangeResult);
                }
                if (rangeResult.getVersions().isEmpty()) {
                    throw new VersionRangeResolutionException(rangeResult, "No versions available for " + dependency.getArtifact() + " within specified range");
                }
            } catch (VersionRangeResolutionException e) {
                addException(args.result, e);
                continue nextDependency;
            }
            List<Version> versions = rangeResult.getVersions();
            for (Version version : versions) {
                Artifact originalArtifact = dependency.getArtifact().setVersion(version.toString());
                Dependency d = dependency.setArtifact(originalArtifact);
                ArtifactDescriptorResult descriptorResult;
                {
                    ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
                    descriptorRequest.setArtifact(d.getArtifact());
                    descriptorRequest.setRepositories(repositories);
                    descriptorRequest.setRequestContext(args.result.getRequest().getRequestContext());
                    descriptorRequest.setTrace(args.trace);
                    if (noDescriptor) {
                        descriptorResult = new ArtifactDescriptorResult(descriptorRequest);
                    } else {
                        Object key = args.pool.toKey(descriptorRequest);
                        descriptorResult = args.pool.getDescriptor(key, descriptorRequest);
                        if (descriptorResult == null) {
                            try {
                                descriptorResult = descriptorReader.readArtifactDescriptor(args.session, descriptorRequest);
                                args.pool.putDescriptor(key, descriptorResult);
                            } catch (ArtifactDescriptorException e) {
                                addException(args.result, e);
                                args.pool.putDescriptor(key, e);
                                continue;
                            }
                        } else if (descriptorResult == DataPool.NO_DESCRIPTOR) {
                            continue;
                        }
                    }
                }
                d = d.setArtifact(descriptorResult.getArtifact());
                GraphNode node = args.edges.top().getTarget();
                GraphEdge cycleEdge = args.edges.find(d.getArtifact());
                if (cycleEdge != null) {
                    GraphEdge edge = new GraphEdge(cycleEdge.getTarget());
                    edge.setDependency(d);
                    edge.setScope(d.getScope());
                    edge.setPremanagedScope(premanagedScope);
                    edge.setPremanagedVersion(premanagedVersion);
                    edge.setRelocations(relocations);
                    edge.setVersionConstraint(rangeResult.getVersionConstraint());
                    edge.setVersion(version);
                    edge.setRequestContext(args.result.getRequest().getRequestContext());
                    node.getOutgoingEdges().add(edge);
                    continue;
                }
                if (!descriptorResult.getRelocations().isEmpty()) {
                    relocations = descriptorResult.getRelocations();
                    disableVersionManagement = originalArtifact.getGroupId().equals(d.getArtifact().getGroupId()) && originalArtifact.getArtifactId().equals(d.getArtifact().getArtifactId());
                    dependency = d;
                    continue thisDependency;
                }
                d = args.pool.intern(d.setArtifact(args.pool.intern(d.getArtifact())));
                DependencySelector childSelector = null;
                DependencyManager childManager = null;
                DependencyTraverser childTraverser = null;
                List<RemoteRepository> childRepos = null;
                Object key = null;
                boolean recurse = traverse && !descriptorResult.getDependencies().isEmpty();
                if (recurse) {
                    DefaultDependencyCollectionContext context = args.collectionContext;
                    context.set(d, descriptorResult.getManagedDependencies());
                    childSelector = depSelector.deriveChildSelector(context);
                    childManager = depManager.deriveChildManager(context);
                    childTraverser = depTraverser.deriveChildTraverser(context);
                    childRepos = remoteRepositoryManager.aggregateRepositories(args.session, repositories, descriptorResult.getRepositories(), true);
                    key = args.pool.toKey(d.getArtifact(), childRepos, childSelector, childManager, childTraverser);
                } else {
                    key = args.pool.toKey(d.getArtifact(), repositories);
                }
                List<RemoteRepository> repos;
                ArtifactRepository repo = rangeResult.getRepository(version);
                if (repo instanceof RemoteRepository) {
                    repos = Collections.singletonList((RemoteRepository) repo);
                } else if (repo == null) {
                    repos = repositories;
                } else {
                    repos = Collections.emptyList();
                }
                GraphNode child = args.pool.getNode(key);
                if (child == null) {
                    child = new GraphNode();
                    child.setAliases(descriptorResult.getAliases());
                    child.setRepositories(repos);
                    args.pool.putNode(key, child);
                } else {
                    recurse = false;
                    if (repos.size() < child.getRepositories().size()) {
                        child.setRepositories(repos);
                    }
                }
                GraphEdge edge = new GraphEdge(child);
                edge.setDependency(d);
                edge.setScope(d.getScope());
                edge.setPremanagedScope(premanagedScope);
                edge.setPremanagedVersion(premanagedVersion);
                edge.setRelocations(relocations);
                edge.setVersionConstraint(rangeResult.getVersionConstraint());
                edge.setVersion(version);
                edge.setRequestContext(args.result.getRequest().getRequestContext());
                node.getOutgoingEdges().add(edge);
                if (recurse) {
                    args.edges.push(edge);
                    process(args, descriptorResult.getDependencies(), childRepos, childSelector, childManager, childTraverser);
                    args.edges.pop();
                }
            }
            break;
        }
    }
}
Also used : VersionRangeResult(org.sonatype.aether.resolution.VersionRangeResult) DependencyManager(org.sonatype.aether.collection.DependencyManager) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) ArtifactRepository(org.sonatype.aether.repository.ArtifactRepository) Dependency(org.sonatype.aether.graph.Dependency) DependencyTraverser(org.sonatype.aether.collection.DependencyTraverser) Artifact(org.sonatype.aether.artifact.Artifact) Version(org.sonatype.aether.version.Version) DependencySelector(org.sonatype.aether.collection.DependencySelector) ArrayList(java.util.ArrayList) List(java.util.List) VersionRangeRequest(org.sonatype.aether.resolution.VersionRangeRequest) ArtifactDescriptorResult(org.sonatype.aether.resolution.ArtifactDescriptorResult) ArtifactDescriptorException(org.sonatype.aether.resolution.ArtifactDescriptorException) DependencyManagement(org.sonatype.aether.collection.DependencyManagement) ArtifactDescriptorRequest(org.sonatype.aether.resolution.ArtifactDescriptorRequest) VersionRangeResolutionException(org.sonatype.aether.resolution.VersionRangeResolutionException)

Example 58 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultMetadataResolver method resolve.

private List<MetadataResult> resolve(RepositorySystemSession session, Collection<? extends MetadataRequest> requests) {
    List<MetadataResult> results = new ArrayList<MetadataResult>(requests.size());
    List<ResolveTask> tasks = new ArrayList<ResolveTask>(requests.size());
    Map<File, Long> localLastUpdates = new HashMap<File, Long>();
    for (MetadataRequest request : requests) {
        RequestTrace trace = DefaultRequestTrace.newChild(request.getTrace(), request);
        MetadataResult result = new MetadataResult(request);
        results.add(result);
        Metadata metadata = request.getMetadata();
        RemoteRepository repository = request.getRepository();
        if (repository == null) {
            LocalRepository localRepo = session.getLocalRepositoryManager().getRepository();
            metadataResolving(session, trace, metadata, localRepo);
            File localFile = getLocalFile(session, metadata);
            if (localFile != null) {
                metadata = metadata.setFile(localFile);
                result.setMetadata(metadata);
            } else {
                result.setException(new MetadataNotFoundException(metadata, localRepo));
            }
            metadataResolved(session, trace, metadata, localRepo, result.getException());
            continue;
        }
        List<RemoteRepository> repositories = getEnabledSourceRepositories(repository, metadata.getNature());
        if (repositories.isEmpty()) {
            continue;
        }
        metadataResolving(session, trace, metadata, repository);
        LocalRepositoryManager lrm = session.getLocalRepositoryManager();
        LocalMetadataRequest localRequest = new LocalMetadataRequest(metadata, repository, request.getRequestContext());
        LocalMetadataResult lrmResult = lrm.find(session, localRequest);
        File metadataFile = lrmResult.getFile();
        if (session.isOffline()) {
            if (metadataFile != null) {
                metadata = metadata.setFile(metadataFile);
                result.setMetadata(metadata);
            } else {
                String msg = "The repository system is offline but the metadata " + metadata + " from " + repository + " is not available in the local repository.";
                result.setException(new MetadataNotFoundException(metadata, repository, msg));
            }
            metadataResolved(session, trace, metadata, repository, result.getException());
            continue;
        }
        Long localLastUpdate = null;
        if (request.isFavorLocalRepository()) {
            File localFile = getLocalFile(session, metadata);
            localLastUpdate = localLastUpdates.get(localFile);
            if (localLastUpdate == null) {
                localLastUpdate = Long.valueOf(localFile != null ? localFile.lastModified() : 0);
                localLastUpdates.put(localFile, localLastUpdate);
            }
        }
        List<UpdateCheck<Metadata, MetadataTransferException>> checks = new ArrayList<UpdateCheck<Metadata, MetadataTransferException>>();
        Exception exception = null;
        for (RemoteRepository repo : repositories) {
            UpdateCheck<Metadata, MetadataTransferException> check = new UpdateCheck<Metadata, MetadataTransferException>();
            check.setLocalLastUpdated((localLastUpdate != null) ? localLastUpdate.longValue() : 0);
            check.setItem(metadata);
            // use 'main' installation file for the check (-> use requested repository)
            File checkFile = new File(session.getLocalRepository().getBasedir(), session.getLocalRepositoryManager().getPathForRemoteMetadata(metadata, repository, request.getRequestContext()));
            check.setFile(checkFile);
            check.setRepository(repository);
            check.setAuthoritativeRepository(repo);
            check.setPolicy(getPolicy(session, repo, metadata.getNature()).getUpdatePolicy());
            if (lrmResult.isStale()) {
                checks.add(check);
            } else {
                updateCheckManager.checkMetadata(session, check);
                if (check.isRequired()) {
                    checks.add(check);
                } else if (exception == null) {
                    exception = check.getException();
                }
            }
        }
        if (!checks.isEmpty()) {
            RepositoryPolicy policy = getPolicy(session, repository, metadata.getNature());
            // install path may be different from lookup path
            File installFile = new File(session.getLocalRepository().getBasedir(), session.getLocalRepositoryManager().getPathForRemoteMetadata(metadata, request.getRepository(), request.getRequestContext()));
            ResolveTask task = new ResolveTask(session, trace, result, installFile, checks, policy.getChecksumPolicy());
            tasks.add(task);
        } else {
            result.setException(exception);
            if (metadataFile != null) {
                metadata = metadata.setFile(metadataFile);
                result.setMetadata(metadata);
            }
            metadataResolved(session, trace, metadata, repository, result.getException());
        }
    }
    if (!tasks.isEmpty()) {
        int threads = ConfigUtils.getInteger(session, 4, "aether.metadataResolver.threads");
        Executor executor = getExecutor(Math.min(tasks.size(), threads));
        try {
            RunnableErrorForwarder errorForwarder = new RunnableErrorForwarder();
            for (ResolveTask task : tasks) {
                executor.execute(errorForwarder.wrap(task));
            }
            errorForwarder.await();
            for (ResolveTask task : tasks) {
                task.result.setException(task.exception);
            }
        } finally {
            shutdown(executor);
        }
        for (ResolveTask task : tasks) {
            Metadata metadata = task.request.getMetadata();
            // re-lookup metadata for resolve
            LocalMetadataRequest localRequest = new LocalMetadataRequest(metadata, task.request.getRepository(), task.request.getRequestContext());
            File metadataFile = session.getLocalRepositoryManager().find(session, localRequest).getFile();
            if (metadataFile != null) {
                metadata = metadata.setFile(metadataFile);
                task.result.setMetadata(metadata);
            }
            if (task.result.getException() == null) {
                task.result.setUpdated(true);
            }
            metadataResolved(session, task.trace, metadata, task.request.getRepository(), task.result.getException());
        }
    }
    return results;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Metadata(org.sonatype.aether.metadata.Metadata) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) RequestTrace(org.sonatype.aether.RequestTrace) DefaultRequestTrace(org.sonatype.aether.util.DefaultRequestTrace) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) Executor(java.util.concurrent.Executor) LocalRepositoryManager(org.sonatype.aether.repository.LocalRepositoryManager) LocalMetadataResult(org.sonatype.aether.repository.LocalMetadataResult) MetadataTransferException(org.sonatype.aether.transfer.MetadataTransferException) RunnableErrorForwarder(org.sonatype.aether.util.concurrency.RunnableErrorForwarder) LocalMetadataRequest(org.sonatype.aether.repository.LocalMetadataRequest) RepositoryPolicy(org.sonatype.aether.repository.RepositoryPolicy) LocalRepository(org.sonatype.aether.repository.LocalRepository) NoRepositoryConnectorException(org.sonatype.aether.transfer.NoRepositoryConnectorException) MetadataNotFoundException(org.sonatype.aether.transfer.MetadataNotFoundException) MetadataTransferException(org.sonatype.aether.transfer.MetadataTransferException) MetadataResult(org.sonatype.aether.resolution.MetadataResult) LocalMetadataResult(org.sonatype.aether.repository.LocalMetadataResult) MetadataNotFoundException(org.sonatype.aether.transfer.MetadataNotFoundException) MetadataRequest(org.sonatype.aether.resolution.MetadataRequest) LocalMetadataRequest(org.sonatype.aether.repository.LocalMetadataRequest) UpdateCheck(org.sonatype.aether.impl.UpdateCheck) File(java.io.File)

Example 59 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultUpdateCheckManager method checkArtifact.

public void checkArtifact(RepositorySystemSession session, UpdateCheck<Artifact, ArtifactTransferException> check) {
    if (check.getLocalLastUpdated() != 0 && !isUpdatedRequired(session, check.getLocalLastUpdated(), check.getPolicy())) {
        if (logger.isDebugEnabled()) {
            logger.debug("Skipped remote update check for " + check.getItem() + ", locally installed artifact up-to-date.");
        }
        check.setRequired(false);
        return;
    }
    Artifact artifact = check.getItem();
    RemoteRepository repository = check.getRepository();
    File artifactFile = check.getFile();
    if (artifactFile == null) {
        throw new IllegalArgumentException(String.format("The artifact '%s' has no file attached", artifact));
    }
    boolean fileExists = check.isFileValid() && artifactFile.exists();
    File touchFile = getTouchFile(artifact, artifactFile);
    Properties props = read(touchFile);
    String updateKey = getUpdateKey(artifactFile, repository);
    String dataKey = getDataKey(artifact, artifactFile, repository);
    String error = getError(props, dataKey);
    long lastUpdated;
    if (fileExists) {
        lastUpdated = artifactFile.lastModified();
    } else if (error == null) {
        // this is the first attempt ever
        lastUpdated = 0;
    } else if (error.length() <= 0) {
        // artifact did not exist
        lastUpdated = getLastUpdated(props, dataKey);
    } else {
        // artifact could not be transferred
        String transferKey = getTransferKey(artifact, artifactFile, repository);
        lastUpdated = getLastUpdated(props, transferKey);
    }
    if (isAlreadyUpdated(session.getData(), updateKey)) {
        if (logger.isDebugEnabled()) {
            logger.debug("Skipped remote update check for " + check.getItem() + ", already updated during this session.");
        }
        check.setRequired(false);
        if (error != null) {
            check.setException(newException(error, artifact, repository));
        }
    } else if (lastUpdated == 0) {
        check.setRequired(true);
    } else if (isUpdatedRequired(session, lastUpdated, check.getPolicy())) {
        check.setRequired(true);
    } else if (fileExists) {
        if (logger.isDebugEnabled()) {
            logger.debug("Skipped remote update check for " + check.getItem() + ", locally cached artifact up-to-date.");
        }
        check.setRequired(false);
    } else {
        if (error == null || error.length() <= 0) {
            if (session.isNotFoundCachingEnabled()) {
                check.setRequired(false);
                check.setException(newException(error, artifact, repository));
            } else {
                check.setRequired(true);
            }
        } else {
            if (session.isTransferErrorCachingEnabled()) {
                check.setRequired(false);
                check.setException(newException(error, artifact, repository));
            } else {
                check.setRequired(true);
            }
        }
    }
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository) Properties(java.util.Properties) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact)

Example 60 with RemoteRepository

use of org.sonatype.aether.repository.RemoteRepository in project sonatype-aether by sonatype.

the class DefaultUpdateCheckManager method getDataKey.

private String getDataKey(Artifact artifact, File artifactFile, RemoteRepository repository) {
    Set<String> mirroredUrls = Collections.emptySet();
    if (repository.isRepositoryManager()) {
        mirroredUrls = new TreeSet<String>();
        for (RemoteRepository mirroredRepository : repository.getMirroredRepositories()) {
            mirroredUrls.add(normalizeRepoUrl(mirroredRepository.getUrl()));
        }
    }
    StringBuilder buffer = new StringBuilder(1024);
    buffer.append(normalizeRepoUrl(repository.getUrl()));
    for (String mirroredUrl : mirroredUrls) {
        buffer.append('+').append(mirroredUrl);
    }
    return buffer.toString();
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository)

Aggregations

RemoteRepository (org.sonatype.aether.repository.RemoteRepository)71 Artifact (org.sonatype.aether.artifact.Artifact)30 Test (org.junit.Test)27 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)18 File (java.io.File)15 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)15 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)13 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)13 Dependency (org.sonatype.aether.graph.Dependency)12 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)12 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)12 LocalArtifactRequest (org.sonatype.aether.repository.LocalArtifactRequest)11 CollectRequest (org.sonatype.aether.collection.CollectRequest)10 LocalArtifactResult (org.sonatype.aether.repository.LocalArtifactResult)10 ArrayList (java.util.ArrayList)8 RepositorySystem (org.sonatype.aether.RepositorySystem)8 IOException (java.io.IOException)7 Before (org.junit.Before)7 Metadata (org.sonatype.aether.metadata.Metadata)7 DependencyRequest (org.sonatype.aether.resolution.DependencyRequest)7