use of org.eclipse.aether.resolution.ArtifactRequest in project BIMserver by opensourceBIM.
the class RemotePluginRepository method main.
public static void main(String[] args) throws ArtifactResolutionException {
System.out.println("------------------------------------------------------------");
System.out.println(RemotePluginRepository.class.getSimpleName());
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system);
Artifact artifact = new DefaultArtifact("org.eclipse.aether:aether-util:1.0.0.v20140518");
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
artifactRequest.setRepositories(newRepositories(system, session));
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
artifact = artifactResult.getArtifact();
System.out.println(artifact + " resolved to " + artifact.getFile());
}
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;
}
use of org.eclipse.aether.resolution.ArtifactRequest in project liferay-ide by liferay.
the class AetherUtil method getLatestAvailableArtifact.
public static Artifact getLatestAvailableArtifact(String gavCoords) {
Artifact retval = null;
RepositorySystem system = newRepositorySystem();
RepositorySystemSession session = newRepositorySystemSession(system);
String latestVersion = getLatestVersion(gavCoords, system, session);
String[] gav = gavCoords.split(":");
Artifact defaultArtifact = new DefaultArtifact(gav[0] + ":" + gav[1] + ":" + latestVersion);
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(defaultArtifact);
artifactRequest.addRepository(newCentralRepository());
try {
ArtifactResult artifactResult = system.resolveArtifact(session, artifactRequest);
retval = artifactResult.getArtifact();
} catch (ArtifactResolutionException e) {
LiferayMavenCore.logError("Unable to get latest Liferay archetype", e);
artifactRequest.setArtifact(new DefaultArtifact(gavCoords));
try {
retval = system.resolveArtifact(session, artifactRequest).getArtifact();
} catch (ArtifactResolutionException e1) {
LiferayMavenCore.logError("Unable to get default Liferay archetype", e1);
}
}
if (retval == null) {
retval = defaultArtifact;
}
return retval;
}
use of org.eclipse.aether.resolution.ArtifactRequest in project fabric8-maven-plugin by fabric8io.
the class AbstractArtifactSearchMojo method resolveArtifactFile.
protected File resolveArtifactFile(HelmIndexMojo.ArtifactDTO artifactDTO, String classifier, String extension) {
File file = null;
try {
ArtifactRequest artifactRequest = new ArtifactRequest();
org.eclipse.aether.artifact.Artifact artifact = new DefaultArtifact(artifactDTO.getG(), artifactDTO.getA(), classifier, extension, artifactDTO.getV());
artifactRequest.setArtifact(artifact);
// convert maven remote repositories to Aether repos
List<RemoteRepository> aetherRepoList = new ArrayList<>();
for (MavenArtifactRepository remoteRepository : remoteRepositories) {
RemoteRepository.Builder builder = new RemoteRepository.Builder(remoteRepository.getId(), remoteRepository.getLayout().getId(), remoteRepository.getUrl());
RemoteRepository aetherRepo = builder.build();
aetherRepoList.add(aetherRepo);
}
artifactRequest.setRepositories(aetherRepoList);
ArtifactResult artifactResult = artifactResolver.resolveArtifact(repoSession, artifactRequest);
org.eclipse.aether.artifact.Artifact resolvedArtifact = artifactResult.getArtifact();
if (resolvedArtifact == null) {
getLog().warn("Could not resolve artifact " + artifactDTO.description());
return null;
}
file = resolvedArtifact.getFile();
} catch (Exception e) {
getLog().warn("Failed to resolve manifest manifest for " + artifactDTO.description() + ". " + e, e);
return null;
}
if (file == null) {
getLog().warn("Could not resolve artifact file for " + artifactDTO.description());
return null;
}
if (!file.isFile() || !file.exists()) {
getLog().warn("Resolved artifact file does not exist for " + artifactDTO.description());
return null;
}
return file;
}
use of org.eclipse.aether.resolution.ArtifactRequest in project revapi by revapi.
the class ArtifactResolver method resolveArtifact.
private Artifact resolveArtifact(Artifact artifact, RepositorySystemSession session) throws ArtifactResolutionException {
ArtifactRequest request = new ArtifactRequest().setArtifact(artifact).setRepositories(repositories);
ArtifactResult result = repositorySystem.resolveArtifact(session, request);
return result.getArtifact();
}
Aggregations