Search in sources :

Example 76 with RemoteRepository

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

the class DependencyContext method fetchArtifactWithDep.

private List<ArtifactResult> fetchArtifactWithDep(Dependency dep) throws DependencyResolutionException, ArtifactResolutionException {
    Artifact artifact = new DefaultArtifact(dep.getGroupArtifactVersion());
    DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
    PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(dep.getExclusions());
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
    collectRequest.addRepository(mavenCentral);
    collectRequest.addRepository(mavenLocal);
    for (Repository repo : repositories) {
        RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
        rr.setPolicy(repo.isSnapshot(), null);
        collectRequest.addRepository(rr);
    }
    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
Also used : RemoteRepository(org.sonatype.aether.repository.RemoteRepository) DependencyRequest(org.sonatype.aether.resolution.DependencyRequest) DependencyFilter(org.sonatype.aether.graph.DependencyFilter) PatternExclusionsDependencyFilter(org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) CollectRequest(org.sonatype.aether.collection.CollectRequest) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) PatternExclusionsDependencyFilter(org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter)

Aggregations

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