use of org.eclipse.aether.resolution.ArtifactRequest in project spring-cloud-function by spring-cloud.
the class DependencyResolutionModule method getArtifactRequests.
private List<ArtifactRequest> getArtifactRequests(List<Dependency> dependencies) {
List<ArtifactRequest> list = new ArrayList<>();
for (Dependency dependency : dependencies) {
ArtifactRequest request = new ArtifactRequest(dependency.getArtifact(), null, null);
request.setRepositories(aetherRepositories(new Properties()));
list.add(request);
}
return list;
}
use of org.eclipse.aether.resolution.ArtifactRequest in project syndesis by syndesisio.
the class RepackageExtensionMojo method downloadAndInstallArtifact.
/*
* @param artifact The artifact coordinates in the format
* {@code <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}, must not be {@code null}.
*
*/
protected ArtifactResult downloadAndInstallArtifact(String artifact) throws MojoExecutionException {
ArtifactResult result;
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(new DefaultArtifact(artifact));
request.setRepositories(remoteRepos);
getLog().info("Resolving artifact " + artifact + " from " + remoteRepos);
try {
result = repoSystem.resolveArtifact(repoSession, request);
return result;
} catch (ArtifactResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
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 grails-maven by grails.
the class AbstractGrailsMojo method resolveArtifactIds.
protected Collection<File> resolveArtifactIds(Collection<String> artifactIds) throws MojoExecutionException {
Collection<ArtifactRequest> requests = new ArrayList<ArtifactRequest>();
for (String artifactId : artifactIds) {
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(new DefaultArtifact(artifactId));
request.setRepositories(remoteRepos);
getLog().debug("Resolving artifact " + artifactId + " from " + remoteRepos);
requests.add(request);
}
Collection<File> files = new ArrayList<File>();
try {
List<ArtifactResult> result = repoSystem.resolveArtifacts(repoSession, requests);
for (ArtifactResult artifactResult : result) {
File file = artifactResult.getArtifact().getFile();
files.add(file);
getLog().debug("Resolved artifact " + artifactResult.getArtifact().getArtifactId() + " to " + file + " from " + artifactResult.getRepository());
}
} catch (ArtifactResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
return files;
}
Aggregations