use of org.eclipse.aether.artifact.DefaultArtifact 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.artifact.DefaultArtifact 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.artifact.DefaultArtifact in project mule by mulesoft.
the class AetherClassPathClassifierTestCase method before.
@Before
public void before() throws Exception {
String muleVersion = getMuleVersion();
this.rootArtifact = new DefaultArtifact("org.foo:foo-root:1.0-SNAPSHOT");
this.loggingDep = new Dependency(new DefaultArtifact("org.mule.runtime:mule-module-logging:" + muleVersion), COMPILE);
this.fooCoreDep = new Dependency(new DefaultArtifact("org.foo:foo-core:1.0-SNAPSHOT"), PROVIDED);
this.fooToolsArtifactDep = new Dependency(new DefaultArtifact("org.foo.tools:foo-artifact:1.0-SNAPSHOT"), PROVIDED);
this.fooTestsSupportDep = new Dependency(new DefaultArtifact("org.foo.tests:foo-tests-support:1.0-SNAPSHOT"), TEST);
this.derbyDriverDep = new Dependency(new DefaultArtifact("org.apache.derby:derby:10.11.1.1"), TEST);
this.guavaDep = new Dependency(new DefaultArtifact("org.google:guava:18.0"), COMPILE);
serviceArtifact = new DefaultArtifact("org.foo:foo-service:jar:mule-service:1.0-SNAPSHOT");
this.fooServiceDep = new Dependency(serviceArtifact, PROVIDED);
this.dependencyResolver = mock(DependencyResolver.class);
this.context = mock(ClassPathClassifierContext.class);
this.artifactClassificationTypeResolver = mock(ArtifactClassificationTypeResolver.class);
this.classifier = new AetherClassPathClassifier(dependencyResolver, artifactClassificationTypeResolver);
when(context.getRootArtifact()).thenReturn(rootArtifact);
this.directDependencies = newArrayList(fooCoreDep, fooToolsArtifactDep, fooTestsSupportDep, derbyDriverDep, guavaDep);
when(dependencyResolver.getDirectDependencies(rootArtifact)).thenReturn(directDependencies);
}
use of org.eclipse.aether.artifact.DefaultArtifact in project mule by mulesoft.
the class DefaultWorkspaceReaderTestCase method before.
@Before
public void before() throws Exception {
artifact = new DefaultArtifact(ORG_FOO_GROUP_ID, BAR, JAR, VERSION);
bar = new File(temporaryFolder.newFolder(ORG_FOO_FOLDER), BAR);
if (!bar.exists()) {
assertThat(bar.mkdir(), is(true));
}
setUpTargetClassesFolder();
}
use of org.eclipse.aether.artifact.DefaultArtifact in project mule by mulesoft.
the class ArtifactIsolatedClassLoaderBuilder method getRootArtifact.
/**
* Gets the Maven artifact located at the given by reading the {@value #POM_XML} file two levels up from target/classes.
*
* @param rootArtifactClassesFolder {@link File} the rootArtifactClassesFolder
* @return {@link Artifact} that represents the rootArtifact
*/
private Artifact getRootArtifact(File rootArtifactClassesFolder) {
File pomFile = new File(rootArtifactClassesFolder.getParentFile().getParentFile(), POM_XML);
logger.debug("Reading rootArtifact from pom file: {}", pomFile);
Model model = MavenModelFactory.createMavenProject(pomFile);
return new DefaultArtifact(model.getGroupId() != null ? model.getGroupId() : model.getParent().getGroupId(), model.getArtifactId(), model.getPackaging(), model.getVersion() != null ? model.getVersion() : model.getParent().getVersion());
}
Aggregations