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());
}
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();
}
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);
}
Aggregations