use of org.eclipse.aether.resolution.ArtifactResolutionException in project mule by mulesoft.
the class AetherClassPathClassifier method getArtifactExportedClasses.
/**
* Resolves the exported plugin classes from the given {@link Artifact}
*
* @param exporterArtifact {@link Artifact} used to resolve the exported classes
* @param context {@link ClassPathClassifierContext} with settings for the classification process
* @param rootArtifactRemoteRepositories remote repositories defined by the rootArtifact
* @return {@link List} of {@link Class} that the given {@link Artifact} exports
*/
private List<Class> getArtifactExportedClasses(Artifact exporterArtifact, ClassPathClassifierContext context, List<RemoteRepository> rootArtifactRemoteRepositories) {
final AtomicReference<URL> artifactUrl = new AtomicReference<>();
try {
artifactUrl.set(dependencyResolver.resolveArtifact(exporterArtifact, rootArtifactRemoteRepositories).getArtifact().getFile().toURI().toURL());
} catch (MalformedURLException | ArtifactResolutionException e) {
throw new IllegalStateException("Unable to resolve artifact URL", e);
}
Artifact rootArtifact = context.getRootArtifact();
return context.getExportPluginClasses().stream().filter(clazz -> {
boolean isFromCurrentArtifact = clazz.getProtectionDomain().getCodeSource().getLocation().equals(artifactUrl.get());
if (isFromCurrentArtifact && exporterArtifact != rootArtifact) {
logger.warn("Exported class '{}' from plugin '{}' is being used from another artifact, {}", clazz.getSimpleName(), exporterArtifact, rootArtifact);
}
return isFromCurrentArtifact;
}).collect(toList());
}
use of org.eclipse.aether.resolution.ArtifactResolutionException 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.ArtifactResolutionException 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.ArtifactResolutionException 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.ArtifactResolutionException in project spf4j by zolyfarkas.
the class ApiChangesMojo method execute.
@Override
public void execute() throws MojoExecutionException {
MavenProject mavenProject = getMavenProject();
try {
getLog().info("Executing JDiff javadoc doclet");
JDiffRunner runner = new JDiffRunner(getMojoExecution(), getToolchainManager(), getMavenSession(), getProjectRepos(), getRepoSystem(), getJavadocExecutable());
runner.runDiffBetweenReleases(mavenProject.getGroupId(), mavenProject.getArtifactId(), this.versionRange, destDir, maxNumberOfDiffs);
runner.writeChangesIndexHtml(destDir, "changes.html");
getLog().info("Generated " + destDir + File.separatorChar + "changes.html");
} catch (IOException | DependencyResolutionException | VersionRangeResolutionException | ArtifactResolutionException | JavadocExecutionException ex) {
throw new MojoExecutionException("Failed executing mojo " + this, ex);
}
}
Aggregations