Search in sources :

Example 31 with DefaultArtifact

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

the class DefaultInstallerTest method setup.

@Before
public void setup() throws IOException {
    artifact = new DefaultArtifact("gid", "aid", "jar", "ver");
    artifact = artifact.setFile(TestFileUtils.createTempFile("artifact".getBytes(), 1));
    metadata = new DefaultMetadata("gid", "aid", "ver", "type", Nature.RELEASE_OR_SNAPSHOT, TestFileUtils.createTempFile("metadata".getBytes(), 1));
    session = new TestRepositorySystemSession();
    localArtifactPath = session.getLocalRepositoryManager().getPathForLocalArtifact(artifact);
    localMetadataPath = session.getLocalRepositoryManager().getPathForLocalMetadata(metadata);
    localArtifactFile = new File(session.getLocalRepository().getBasedir(), localArtifactPath);
    installer = new DefaultInstaller();
    installer.setFileProcessor(TestFileProcessor.INSTANCE);
    installer.setRepositoryEventDispatcher(new StubRepositoryEventDispatcher());
    installer.setSyncContextFactory(new StubSyncContextFactory());
    request = new InstallRequest();
    listener = new RecordingRepositoryListener();
    session.setRepositoryListener(listener);
    lrm = (TestLocalRepositoryManager) session.getLocalRepositoryManager();
    TestFileUtils.delete(session.getLocalRepository().getBasedir());
}
Also used : TestRepositorySystemSession(org.sonatype.aether.test.impl.TestRepositorySystemSession) InstallRequest(org.sonatype.aether.installation.InstallRequest) DefaultMetadata(org.sonatype.aether.util.metadata.DefaultMetadata) RecordingRepositoryListener(org.sonatype.aether.test.impl.RecordingRepositoryListener) File(java.io.File) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) Before(org.junit.Before)

Example 32 with DefaultArtifact

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

the class Dependency30Helper method resolveById.

@Override
public File resolveById(String id, Log log) throws MojoFailureException {
    if (id.startsWith("mvn:")) {
        if (id.contains("!")) {
            id = id.substring(0, "mvn:".length()) + id.substring(id.indexOf("!") + 1);
        }
        if (id.endsWith("/")) {
            id = id.substring(0, id.length() - 1);
        }
    }
    id = MavenUtil.mvnToAether(id);
    ArtifactRequest request = new ArtifactRequest();
    request.setArtifact(new DefaultArtifact(id));
    request.setRepositories(projectRepositories);
    log.debug("Resolving artifact " + id + " from " + projectRepositories);
    ArtifactResult result;
    try {
        result = repositorySystem.resolveArtifact(repositorySystemSession, request);
    } catch (ArtifactResolutionException e) {
        log.warn("Could not resolve " + id, e);
        throw new MojoFailureException(format("Couldn't resolve artifact %s", id), e);
    }
    log.debug("Resolved artifact " + id + " to " + result.getArtifact().getFile() + " from " + result.getRepository());
    return result.getArtifact().getFile();
}
Also used : ArtifactResolutionException(org.sonatype.aether.resolution.ArtifactResolutionException) ArtifactRequest(org.sonatype.aether.resolution.ArtifactRequest) MojoFailureException(org.apache.maven.plugin.MojoFailureException) DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact) ArtifactResult(org.sonatype.aether.resolution.ArtifactResult)

Example 33 with DefaultArtifact

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

the class Dependency30Helper method pathFromAether.

@Override
public String pathFromAether(String name) {
    DefaultArtifact artifact = new DefaultArtifact(name);
    org.apache.maven.artifact.Artifact mavenArtifact = RepositoryUtils.toArtifact(artifact);
    return MavenUtil.layout.pathOf(mavenArtifact);
}
Also used : DefaultArtifact(org.sonatype.aether.util.artifact.DefaultArtifact)

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