use of org.eclipse.aether.resolution.ArtifactResult in project launcher by runelite.
the class ArtifactResolverTest method test.
@Test
@Ignore
public void test() throws Exception {
ArtifactResolver resolver = new ArtifactResolver(folder.newFolder());
resolver.addRepositories();
Artifact a = new DefaultArtifact("net.runelite", "client", "", "jar", "1.0.0-SNAPSHOT");
List<ArtifactResult> artifacts = resolver.resolveArtifacts(a);
for (ArtifactResult a2 : artifacts) System.out.println(a2.getArtifact().getFile());
}
use of org.eclipse.aether.resolution.ArtifactResult in project mule by mulesoft.
the class DefaultRepositoryService method lookupBundle.
@Override
public File lookupBundle(BundleDependency bundleDependency) {
try {
if (remoteRepositories.isEmpty()) {
throw new RepositoryServiceDisabledException("Repository service has not been configured so it's disabled. " + "To enable it you must configure the set of repositories to use using the system property: " + MULE_REMOTE_REPOSITORIES_PROPERTY);
}
DefaultArtifact artifact = toArtifact(bundleDependency);
ArtifactRequest getArtifactRequest = new ArtifactRequest();
getArtifactRequest.setRepositories(remoteRepositories);
getArtifactRequest.setArtifact(artifact);
ArtifactResult artifactResult = repositorySystem.resolveArtifact(repositorySystemSession, getArtifactRequest);
return artifactResult.getArtifact().getFile();
} catch (ArtifactResolutionException e) {
if (e.getCause() instanceof ArtifactNotFoundException) {
throw new BundleNotFoundException(e);
} else {
throw new RepositoryConnectionException("There was a problem connecting to one of the repositories", e);
}
}
}
use of org.eclipse.aether.resolution.ArtifactResult in project mule by mulesoft.
the class ExtensionModelLoaderFinder method findLoaderByProperty.
/**
* Searches in the plugin pom.xml for the {@code testExtensionModelLoaderId} property which specifies with which loader the
* extension must be loaded. The main use of this is for Test Extensions that don't generate a mule-artifact.json.
*/
public Optional<ExtensionModelLoader> findLoaderByProperty(Artifact plugin, DependencyResolver dependencyResolver, List<RemoteRepository> rootArtifactRemoteRepositories) {
DefaultArtifact artifact = new DefaultArtifact(plugin.getGroupId(), plugin.getArtifactId(), "pom", plugin.getVersion());
try {
ArtifactResult artifactResult = dependencyResolver.resolveArtifact(artifact, rootArtifactRemoteRepositories);
File pomFile = artifactResult.getArtifact().getFile();
Model mavenProject = MavenModelFactory.createMavenProject(pomFile);
String id = mavenProject.getProperties().getProperty("testExtensionModelLoaderId");
return id != null ? Optional.ofNullable(getLoaderById(id)) : Optional.empty();
} catch (ArtifactResolutionException e) {
throw new RuntimeException("Cannot load extension, the artifact: [" + plugin.toString() + "] cannot be resolved", e);
}
}
use of org.eclipse.aether.resolution.ArtifactResult in project mule by mulesoft.
the class AetherClassPathClassifierTestCase method onlyProvidedDependenciesNoTransitiveNoManageDependenciesNoFilters.
@Test
public void onlyProvidedDependenciesNoTransitiveNoManageDependenciesNoFilters() throws Exception {
Dependency compileMuleCoreDep = fooCoreDep.setScope(COMPILE);
Dependency compileMuleArtifactDep = fooToolsArtifactDep.setScope(COMPILE);
when(artifactClassificationTypeResolver.resolveArtifactClassificationType(rootArtifact)).thenReturn(MODULE);
ArtifactDescriptorResult artifactDescriptorResult = mock(ArtifactDescriptorResult.class);
List<Dependency> managedDependencies = newArrayList(guavaDep);
when(artifactDescriptorResult.getManagedDependencies()).thenReturn(managedDependencies);
when(dependencyResolver.readArtifactDescriptor(any(Artifact.class))).thenReturn(artifactDescriptorResult);
File rootArtifactFile = temporaryFolder.newFile();
File fooCoreArtifactFile = temporaryFolder.newFile();
File fooToolsArtifactFile = temporaryFolder.newFile();
Artifact jarRootArtifact = rootArtifact.setFile(rootArtifactFile);
ArtifactResult rootArtifactResult = mock(ArtifactResult.class);
when(rootArtifactResult.getArtifact()).thenReturn(jarRootArtifact);
when(dependencyResolver.resolveArtifact(argThat(new ArtifactMatcher(rootArtifact.getGroupId(), rootArtifact.getArtifactId())))).thenReturn(rootArtifactResult);
when(dependencyResolver.resolveDependencies(argThat(nullValue(Dependency.class)), (List<Dependency>) argThat(hasItems(equalTo(compileMuleCoreDep), equalTo(compileMuleArtifactDep), equalTo(loggingDep))), (List<Dependency>) argThat(hasItems(equalTo(guavaDep))), argThat(instanceOf(DependencyFilter.class)), argThat(equalTo(emptyList())))).thenReturn(newArrayList(fooCoreArtifactFile, fooToolsArtifactFile));
ArtifactsUrlClassification classification = classifier.classify(context);
assertThat(classification.getTestRunnerLibUrls(), is(empty()));
assertThat(classification.getPluginUrlClassifications(), is(empty()));
assertThat(classification.getApplicationSharedLibUrls(), is(empty()));
assertThat(classification.getContainerUrls(), hasSize(3));
assertThat(classification.getContainerUrls(), hasItems(fooCoreArtifactFile.toURI().toURL(), fooToolsArtifactFile.toURI().toURL(), rootArtifactFile.toURI().toURL()));
verify(artifactDescriptorResult, atLeastOnce()).getManagedDependencies();
verify(dependencyResolver, atLeastOnce()).readArtifactDescriptor(any(Artifact.class));
verify(dependencyResolver).resolveDependencies(argThat(nullValue(Dependency.class)), (List<Dependency>) argThat(hasItems(equalTo(compileMuleCoreDep), equalTo(compileMuleArtifactDep), equalTo(loggingDep))), (List<Dependency>) argThat(hasItems(equalTo(guavaDep))), argThat(instanceOf(DependencyFilter.class)), argThat(equalTo(emptyList())));
verify(artifactClassificationTypeResolver).resolveArtifactClassificationType(rootArtifact);
verify(rootArtifactResult).getArtifact();
}
use of org.eclipse.aether.resolution.ArtifactResult in project mule by mulesoft.
the class AetherClassPathClassifierTestCase method appendApplicationUrls.
@Test
public void appendApplicationUrls() throws Exception {
Dependency compileMuleCoreDep = fooCoreDep.setScope(COMPILE);
Dependency compileMuleArtifactDep = fooToolsArtifactDep.setScope(COMPILE);
when(artifactClassificationTypeResolver.resolveArtifactClassificationType(rootArtifact)).thenReturn(APPLICATION);
ArtifactDescriptorResult artifactDescriptorResult = mock(ArtifactDescriptorResult.class);
List<Dependency> managedDependencies = newArrayList(guavaDep);
when(artifactDescriptorResult.getManagedDependencies()).thenReturn(managedDependencies);
when(dependencyResolver.readArtifactDescriptor(any(Artifact.class), any(List.class))).thenReturn(artifactDescriptorResult);
artifactDescriptorResult = mock(ArtifactDescriptorResult.class);
when(artifactDescriptorResult.getRepositories()).thenReturn(emptyList());
when(dependencyResolver.readArtifactDescriptor(argThat(new ArtifactMatcher(rootArtifact.getGroupId(), rootArtifact.getArtifactId())))).thenReturn(artifactDescriptorResult);
File rootArtifactFile = temporaryFolder.newFile();
File fooCoreArtifactFile = temporaryFolder.newFile();
File fooToolsArtifactFile = temporaryFolder.newFile();
Artifact jarRootArtifact = rootArtifact.setFile(rootArtifactFile);
ArtifactResult rootArtifactResult = mock(ArtifactResult.class);
when(rootArtifactResult.getArtifact()).thenReturn(jarRootArtifact);
when(dependencyResolver.resolveArtifact(argThat(new ArtifactMatcher(rootArtifact.getGroupId(), rootArtifact.getArtifactId())))).thenReturn(rootArtifactResult);
when(dependencyResolver.resolveDependencies(argThat(nullValue(Dependency.class)), (List<Dependency>) argThat(hasItems(equalTo(compileMuleCoreDep), equalTo(compileMuleArtifactDep))), (List<Dependency>) argThat(hasItems(equalTo(guavaDep))), argThat(instanceOf(DependencyFilter.class)), argThat(equalTo(emptyList())))).thenReturn(newArrayList(fooCoreArtifactFile, fooToolsArtifactFile));
URL url = temporaryFolder.newFile().toURI().toURL();
List<URL> testRunnerUrls = newArrayList(url);
when(context.getTestRunnerPluginUrls()).thenReturn(testRunnerUrls);
ArtifactsUrlClassification classification = classifier.classify(context);
assertThat(classification.getTestRunnerLibUrls(), hasSize(2));
assertThat(classification.getTestRunnerLibUrls(), contains(rootArtifactFile.toURI().toURL(), url));
assertThat(classification.getPluginUrlClassifications(), is(empty()));
assertThat(classification.getApplicationSharedLibUrls(), is(empty()));
assertThat(classification.getContainerUrls(), hasSize(2));
assertThat(classification.getContainerUrls(), hasItems(fooCoreArtifactFile.toURI().toURL(), fooToolsArtifactFile.toURI().toURL()));
verify(artifactDescriptorResult, atLeastOnce()).getManagedDependencies();
verify(dependencyResolver, atLeastOnce()).readArtifactDescriptor(any(Artifact.class), any(List.class));
verify(dependencyResolver).resolveDependencies(argThat(nullValue(Dependency.class)), (List<Dependency>) argThat(hasItems(equalTo(compileMuleCoreDep), equalTo(compileMuleArtifactDep))), (List<Dependency>) argThat(hasItems(equalTo(guavaDep))), argThat(instanceOf(DependencyFilter.class)), argThat(equalTo(emptyList())));
verify(artifactClassificationTypeResolver).resolveArtifactClassificationType(rootArtifact);
verify(context, atLeastOnce()).getTestRunnerPluginUrls();
verify(rootArtifactResult).getArtifact();
}
Aggregations