use of org.eclipse.aether.resolution.ArtifactRequest in project sts4 by spring-projects.
the class MavenBridge method resolve.
public Artifact resolve(final Artifact artifact, List<ArtifactRepository> remoteRepositories, MavenExecutionRequest executionRequest) throws MavenException {
if (remoteRepositories == null) {
try {
remoteRepositories = getArtifactRepositories();
} catch (MavenException e) {
// we've tried
remoteRepositories = Collections.emptyList();
}
}
final List<ArtifactRepository> _remoteRepositories = remoteRepositories;
org.eclipse.aether.RepositorySystem repoSystem = lookup(org.eclipse.aether.RepositorySystem.class);
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(RepositoryUtils.toArtifact(artifact));
request.setRepositories(RepositoryUtils.toRepos(_remoteRepositories));
ArtifactResult result;
try {
result = repoSystem.resolveArtifact(createRepositorySession(executionRequest), request);
} catch (ArtifactResolutionException ex) {
result = ex.getResults().get(0);
}
setLastUpdated(executionRequest.getLocalRepository(), _remoteRepositories, artifact);
if (result.isResolved()) {
artifact.selectVersion(result.getArtifact().getVersion());
artifact.setFile(result.getArtifact().getFile());
artifact.setResolved(true);
} else {
throw new MavenException(result.getExceptions().toArray(new Exception[result.getExceptions().size()]));
}
return artifact;
}
use of org.eclipse.aether.resolution.ArtifactRequest in project unleash-maven-plugin by shillner.
the class ArtifactCacheLoader method load.
@Override
public Optional<ArtifactResult> load(ArtifactCoordinates coordinates) throws Exception {
Artifact artifact = new DefaultArtifact(coordinates.toString());
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setRepositories(this.remoteProjectRepos);
ArtifactResult artifactResult;
try {
artifactResult = this.repoSystem.resolveArtifact(this.repoSession, artifactRequest);
} catch (ArtifactResolutionException e) {
// must not throw the error or log as an error since this is an expected behavior
artifactResult = null;
}
return Optional.fromNullable(artifactResult);
}
use of org.eclipse.aether.resolution.ArtifactRequest in project karaf by apache.
the class Dependency31Helper method resolveArtifact.
private ArtifactResult resolveArtifact(Artifact artifact) throws ArtifactResolutionException {
ArtifactResult result = artifactCache.get(artifact);
if (result != null) {
return result;
}
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(artifact);
request.setRepositories(projectRepositories);
result = repositorySystem.resolveArtifact(repositorySystemSession, request);
if (result != null) {
artifactCache.put(artifact, result);
}
return result;
}
Aggregations