Search in sources :

Example 26 with Artifact

use of org.sonatype.aether.artifact.Artifact in project gradle by gradle.

the class MavenInstallAction method publishArtifacts.

@Override
protected void publishArtifacts(Collection<Artifact> artifacts, RepositorySystem repositorySystem, RepositorySystemSession session) throws InstallationException {
    InstallRequest request = new InstallRequest();
    for (Artifact artifact : artifacts) {
        request.addArtifact(artifact);
    }
    repositorySystem.install(session, request);
}
Also used : InstallRequest(org.sonatype.aether.installation.InstallRequest) Artifact(org.sonatype.aether.artifact.Artifact)

Example 27 with Artifact

use of org.sonatype.aether.artifact.Artifact in project presto by prestodb.

the class PluginManager method buildClassLoaderFromCoordinates.

private URLClassLoader buildClassLoaderFromCoordinates(String coordinates) throws Exception {
    Artifact rootArtifact = new DefaultArtifact(coordinates);
    List<Artifact> artifacts = resolver.resolveArtifacts(rootArtifact);
    return createClassLoader(artifacts, rootArtifact.toString());
}
Also used : Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(io.airlift.resolver.DefaultArtifact) DefaultArtifact(io.airlift.resolver.DefaultArtifact)

Example 28 with Artifact

use of org.sonatype.aether.artifact.Artifact in project presto by prestodb.

the class PluginManager method buildClassLoaderFromPom.

private URLClassLoader buildClassLoaderFromPom(File pomFile) throws Exception {
    List<Artifact> artifacts = resolver.resolvePom(pomFile);
    URLClassLoader classLoader = createClassLoader(artifacts, pomFile.getPath());
    Artifact artifact = artifacts.get(0);
    Set<String> plugins = discoverPlugins(artifact, classLoader);
    if (!plugins.isEmpty()) {
        writePluginServices(plugins, artifact.getFile());
    }
    return classLoader;
}
Also used : URLClassLoader(java.net.URLClassLoader) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(io.airlift.resolver.DefaultArtifact)

Example 29 with Artifact

use of org.sonatype.aether.artifact.Artifact in project zeppelin by apache.

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)

Example 30 with Artifact

use of org.sonatype.aether.artifact.Artifact in project zeppelin by apache.

the class DependencyResolver method getArtifactsWithDep.

/**
   * @param dependency
   * @param excludes list of pattern can either be of the form groupId:artifactId
   * @return
   * @throws Exception
   */
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency, Collection<String> excludes) throws RepositoryException {
    Artifact artifact = new DefaultArtifact(dependency);
    DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
    PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(excludes);
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
    synchronized (repos) {
        for (RemoteRepository repo : repos) {
            collectRequest.addRepository(repo);
        }
    }
    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
    try {
        return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
    } catch (NullPointerException ex) {
        throw new RepositoryException(String.format("Cannot fetch dependencies for %s", dependency));
    }
}
Also used : 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) RepositoryException(org.sonatype.aether.RepositoryException) Dependency(org.sonatype.aether.graph.Dependency) 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

Artifact (org.sonatype.aether.artifact.Artifact)116 Test (org.junit.Test)63 File (java.io.File)33 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)30 StubArtifact (org.sonatype.aether.test.util.impl.StubArtifact)28 DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)27 Dependency (org.sonatype.aether.graph.Dependency)22 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)17 ArtifactDownload (org.sonatype.aether.spi.connector.ArtifactDownload)16 LocalArtifactRequest (org.sonatype.aether.repository.LocalArtifactRequest)15 LocalArtifactResult (org.sonatype.aether.repository.LocalArtifactResult)15 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)14 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)13 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)13 ArrayList (java.util.ArrayList)12 ArtifactTransferException (org.sonatype.aether.transfer.ArtifactTransferException)12 Metadata (org.sonatype.aether.metadata.Metadata)10 RepositorySystem (org.sonatype.aether.RepositorySystem)9 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8