use of org.eclipse.aether.resolution.ArtifactResult in project pinpoint by naver.
the class DependencyResolver method resolveArtifactsAndDependencies.
public List<File> resolveArtifactsAndDependencies(List<Artifact> artifacts) throws DependencyResolutionException {
List<Dependency> dependencies = new ArrayList<>();
for (Artifact artifact : artifacts) {
dependencies.add(new Dependency(artifact, JavaScopes.RUNTIME));
}
CollectRequest collectRequest = new CollectRequest((Dependency) null, dependencies, repositories);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME);
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, classpathFilter);
DependencyResult result = system.resolveDependencies(session, dependencyRequest);
List<File> files = new ArrayList<>();
for (ArtifactResult artifactResult : result.getArtifactResults()) {
files.add(artifactResult.getArtifact().getFile());
}
return files;
}
use of org.eclipse.aether.resolution.ArtifactResult 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.ArtifactResult in project launcher by runelite.
the class ReflectionLauncher method launch.
public static void launch(List<ArtifactResult> results, String clientArgs, OptionSet options) throws Exception {
URL[] jarUrls = new URL[results.size()];
int i = 0;
for (ArtifactResult ar : results) {
URL url = ar.getArtifact().getFile().toURI().toURL();
logger.debug("Adding jar: {}", url);
jarUrls[i++] = url;
}
URLClassLoader loader = new URLClassLoader(jarUrls, null);
// hack for Substance
UIManager.put("ClassLoader", loader);
Thread thread = new Thread() {
public void run() {
try {
Class<?> mainClass = loader.loadClass(CLIENT_MAIN_CLASS);
Method main = mainClass.getMethod("main", String[].class);
String[] args = clientArgs != null ? clientArgs.split(" ") : new String[0];
main.invoke(null, (Object) args);
} catch (Exception ex) {
ex.printStackTrace();
}
}
};
thread.setName("RuneLite");
thread.start();
}
use of org.eclipse.aether.resolution.ArtifactResult 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.ArtifactResult in project zeppelin by apache.
the class DependencyResolver method loadFromMvn.
private List<File> loadFromMvn(String artifact, Collection<String> excludes) throws RepositoryException {
Collection<String> allExclusions = new LinkedList<>();
allExclusions.addAll(excludes);
allExclusions.addAll(Arrays.asList(exclusions));
List<ArtifactResult> listOfArtifact;
listOfArtifact = getArtifactsWithDep(artifact, allExclusions);
Iterator<ArtifactResult> it = listOfArtifact.iterator();
while (it.hasNext()) {
Artifact a = it.next().getArtifact();
String gav = a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getVersion();
for (String exclude : allExclusions) {
if (gav.startsWith(exclude)) {
it.remove();
break;
}
}
}
List<File> files = new LinkedList<>();
for (ArtifactResult artifactResult : listOfArtifact) {
files.add(artifactResult.getArtifact().getFile());
LOGGER.debug("load {}", artifactResult.getArtifact().getFile().getAbsolutePath());
}
return files;
}
Aggregations