Search in sources :

Example 16 with DefaultArtifact

use of org.sonatype.aether.util.artifact.DefaultArtifact in project sonatype-aether by sonatype.

the class AetherDemo method installAndDeploy.

public void installAndDeploy() throws InstallationException, DeploymentException {
    Aether aether = new Aether("http://localhost:8081/nexus/content/groups/public", "/Users/jvanzyl/aether-repo");
    Artifact artifact = new DefaultArtifact("com.mycompany.super", "super-core", "jar", "0.1-SNAPSHOT");
    artifact = artifact.setFile(new File("jar-from-whatever-process.jar"));
    Artifact pom = new SubArtifact(artifact, null, "pom");
    pom = pom.setFile(new File("pom-from-whatever-process.xml"));
    // Install into the local repository specified
    //
    aether.install(artifact, pom);
    // Deploy to a remote reposistory
    //
    aether.deploy(artifact, pom, "http://localhost:8081/nexus/content/repositories/snapshots/");
}
Also used : SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) SubArtifact(org.sonatype.aether.util.artifact.SubArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Example 17 with DefaultArtifact

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

the class SparkDependencyContext method fetchArtifactWithDep.

private List<ArtifactResult> fetchArtifactWithDep(Dependency dep) throws DependencyResolutionException, ArtifactResolutionException {
    Artifact artifact = new DefaultArtifact(SparkDependencyResolver.inferScalaVersion(dep.getGroupArtifactVersion()));
    DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
    PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(SparkDependencyResolver.inferScalaVersion(dep.getExclusions()));
    CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new org.sonatype.aether.graph.Dependency(artifact, JavaScopes.COMPILE));
    collectRequest.addRepository(mavenCentral);
    collectRequest.addRepository(mavenLocal);
    for (RemoteRepository repo : additionalRepos) {
        collectRequest.addRepository(repo);
    }
    for (Repository repo : repositories) {
        RemoteRepository rr = new RemoteRepository(repo.getId(), "default", repo.getUrl());
        rr.setPolicy(repo.isSnapshot(), null);
        Authentication auth = repo.getAuthentication();
        if (auth != null) {
            rr.setAuthentication(auth);
        }
        collectRequest.addRepository(rr);
    }
    DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFlter));
    return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
}
Also used : Repository(org.apache.zeppelin.dep.Repository) RemoteRepository(org.sonatype.aether.repository.RemoteRepository) DependencyRequest(org.sonatype.aether.resolution.DependencyRequest) Authentication(org.sonatype.aether.repository.Authentication) 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 18 with DefaultArtifact

use of org.sonatype.aether.util.artifact.DefaultArtifact in project storm by apache.

the class AetherUtilsTest method artifactToString.

@Test
public void artifactToString() throws Exception {
    Artifact testArtifact = new DefaultArtifact("org.apache.storm:storm-core:1.0.0");
    String ret = AetherUtils.artifactToString(testArtifact);
    assertEquals("org.apache.storm:storm-core:jar:1.0.0", ret);
}
Also used : Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Test(org.junit.Test)

Example 19 with DefaultArtifact

use of org.sonatype.aether.util.artifact.DefaultArtifact in project gradle by gradle.

the class AbstractMavenPublishAction method createTypedArtifact.

private Artifact createTypedArtifact(String type, String classifier) {
    String extension = type;
    ArtifactType stereotype = session.getArtifactTypeRegistry().get(type);
    if (stereotype != null) {
        extension = stereotype.getExtension();
        if (classifier == null) {
            classifier = stereotype.getClassifier();
        }
    }
    return new DefaultArtifact(pomArtifact.getGroupId(), pomArtifact.getArtifactId(), classifier, extension, pomArtifact.getVersion());
}
Also used : ArtifactType(org.sonatype.aether.artifact.ArtifactType) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

Example 20 with DefaultArtifact

use of org.sonatype.aether.util.artifact.DefaultArtifact in project sonatype-aether by sonatype.

the class SimpleLocalRepositoryManagerTest method testFindArtifactUsesTimestampedVersion.

@Test
public void testFindArtifactUsesTimestampedVersion() throws Exception {
    Artifact artifact = new DefaultArtifact("g.i.d:a.i.d:1.0-SNAPSHOT");
    File file = new File(basedir, manager.getPathForLocalArtifact(artifact));
    TestFileUtils.write("test", file);
    artifact = artifact.setVersion("1.0-20110329.221805-4");
    LocalArtifactRequest request = new LocalArtifactRequest();
    request.setArtifact(artifact);
    LocalArtifactResult result = manager.find(session, request);
    assertNull(result.toString(), result.getFile());
    assertFalse(result.toString(), result.isAvailable());
}
Also used : LocalArtifactResult(org.sonatype.aether.repository.LocalArtifactResult) File(java.io.File) Artifact(org.sonatype.aether.artifact.Artifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) LocalArtifactRequest(org.sonatype.aether.repository.LocalArtifactRequest) Test(org.junit.Test)

Aggregations

DefaultArtifact (org.sonatype.aether.util.artifact.DefaultArtifact)33 Artifact (org.sonatype.aether.artifact.Artifact)23 RemoteRepository (org.sonatype.aether.repository.RemoteRepository)18 Test (org.junit.Test)10 RepositorySystemSession (org.sonatype.aether.RepositorySystemSession)10 File (java.io.File)9 RepositorySystem (org.sonatype.aether.RepositorySystem)9 Dependency (org.sonatype.aether.graph.Dependency)9 CollectRequest (org.sonatype.aether.collection.CollectRequest)8 DependencyRequest (org.sonatype.aether.resolution.DependencyRequest)6 DependencyFilter (org.sonatype.aether.graph.DependencyFilter)5 ArtifactResult (org.sonatype.aether.resolution.ArtifactResult)4 PatternExclusionsDependencyFilter (org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter)4 Before (org.junit.Before)3 TestRepositorySystemSession (org.sonatype.aether.test.impl.TestRepositorySystemSession)3 SubArtifact (org.sonatype.aether.util.artifact.SubArtifact)3 DefaultMetadata (org.sonatype.aether.util.metadata.DefaultMetadata)3 ConsoleDependencyGraphDumper (demo.util.ConsoleDependencyGraphDumper)2 CollectResult (org.sonatype.aether.collection.CollectResult)2 DeployRequest (org.sonatype.aether.deployment.DeployRequest)2