use of org.eclipse.aether.resolution.ArtifactResolutionException in project revapi by revapi.
the class ReportAggregateMojo method getRunConfig.
private ProjectVersions getRunConfig(MavenProject project) {
ProjectVersions ret = new ProjectVersions();
Plugin revapiPlugin = findRevapi(project);
if (revapiPlugin == null) {
return ret;
}
Xpp3Dom pluginConfig = (Xpp3Dom) revapiPlugin.getConfiguration();
String[] oldArtifacts = getArtifacts(pluginConfig, "oldArtifacts");
String[] newArtifacts = getArtifacts(pluginConfig, "newArtifacts");
String oldVersion = getValueOfChild(pluginConfig, "oldVersion");
if (oldVersion == null) {
oldVersion = System.getProperties().getProperty(Props.oldVersion.NAME, Props.oldVersion.DEFAULT_VALUE);
}
String newVersion = getValueOfChild(pluginConfig, "newVersion");
if (newVersion == null) {
newVersion = System.getProperties().getProperty(Props.newVersion.NAME, project.getVersion());
}
String defaultOldArtifact = Analyzer.getProjectArtifactCoordinates(project, oldVersion);
String defaultNewArtifact = Analyzer.getProjectArtifactCoordinates(project, newVersion);
if (oldArtifacts == null || oldArtifacts.length == 0) {
if (!project.getArtifact().getArtifactHandler().isAddedToClasspath()) {
return ret;
}
oldArtifacts = new String[] { defaultOldArtifact };
}
if (newArtifacts == null || newArtifacts.length == 0) {
if (!project.getArtifact().getArtifactHandler().isAddedToClasspath()) {
return ret;
}
newArtifacts = new String[] { defaultNewArtifact };
}
String versionRegexString = getValueOfChild(pluginConfig, "versionFormat");
Pattern versionRegex = versionRegexString == null ? null : Pattern.compile(versionRegexString);
DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(repositorySystemSession);
session.setDependencySelector(new ScopeDependencySelector("compile", "provided"));
session.setDependencyTraverser(new ScopeDependencyTraverser("compile", "provided"));
if (alwaysCheckForReleaseVersion) {
session.setUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS);
}
ArtifactResolver resolver = new ArtifactResolver(repositorySystem, session, mavenSession.getCurrentProject().getRemoteProjectRepositories());
Function<String, Artifact> resolve = gav -> {
try {
return Analyzer.resolveConstrained(project, gav, versionRegex, resolver);
} catch (VersionRangeResolutionException | ArtifactResolutionException e) {
getLog().warn("Could not resolve artifact '" + gav + "' with message: " + e.getMessage());
return null;
}
};
ret.oldGavs = Stream.of(oldArtifacts).map(resolve).filter(f -> f != null).toArray(Artifact[]::new);
ret.newGavs = Stream.of(newArtifacts).map(resolve).filter(f -> f != null).toArray(Artifact[]::new);
return ret;
}
use of org.eclipse.aether.resolution.ArtifactResolutionException in project activemq-artemis by apache.
the class ArtemisAbstractPlugin method resolveArtifact.
protected File resolveArtifact(Artifact artifact) throws MojoExecutionException, DependencyCollectionException {
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(artifact);
request.setRepositories(remoteRepos);
ArtifactResult result;
try {
result = repositorySystem.resolveArtifact(repoSession, request);
} catch (ArtifactResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
return result.getArtifact().getFile();
}
use of org.eclipse.aether.resolution.ArtifactResolutionException in project spring-boot by spring-projects.
the class MavenResolverGrapeEngine method grab.
@Override
public Object grab(Map args, Map... dependencyMaps) {
List<Exclusion> exclusions = createExclusions(args);
List<Dependency> dependencies = createDependencies(dependencyMaps, exclusions);
try {
List<File> files = resolve(dependencies);
GroovyClassLoader classLoader = getClassLoader(args);
for (File file : files) {
classLoader.addURL(file.toURI().toURL());
}
} catch (ArtifactResolutionException | MalformedURLException ex) {
throw new DependencyResolutionFailedException(ex);
}
return null;
}
use of org.eclipse.aether.resolution.ArtifactResolutionException in project grails-maven by grails.
the class AbstractGrailsMojo method resolveArtifact.
protected File resolveArtifact(String artifactId) throws MojoExecutionException {
ArtifactRequest request = new ArtifactRequest();
request.setArtifact(new DefaultArtifact(artifactId));
request.setRepositories(remoteRepos);
getLog().debug("Resolving artifact " + artifactId + " from " + remoteRepos);
ArtifactResult result;
File file;
try {
result = repoSystem.resolveArtifact(repoSession, request);
file = result.getArtifact().getFile();
} catch (ArtifactResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
getLog().debug("Resolved artifact " + artifactId + " to " + file + " from " + result.getRepository());
return file;
}
use of org.eclipse.aether.resolution.ArtifactResolutionException in project drools by kiegroup.
the class MavenRepository method resolveArtifact.
public Artifact resolveArtifact(String artifactName, boolean logUnresolvedArtifact) {
Artifact artifact = new DefaultArtifact(artifactName);
ArtifactRequest artifactRequest = new ArtifactRequest();
artifactRequest.setArtifact(artifact);
for (RemoteRepository repo : remoteRepositoriesForRequest) {
artifactRequest.addRepository(repo);
}
RepositorySystemSession session = aether.getSession();
Object sessionChecks = null;
boolean isSnapshot = artifactName.endsWith("-SNAPSHOT");
if (artifactName.endsWith("-SNAPSHOT")) {
// ensure to always update snapshots
sessionChecks = session.getData().get(SESSION_CHECKS);
session.getData().set(SESSION_CHECKS, null);
}
try {
ArtifactResult artifactResult = aether.getSystem().resolveArtifact(session, artifactRequest);
return artifactResult.getArtifact();
} catch (ArtifactResolutionException e) {
if (logUnresolvedArtifact) {
if (log.isDebugEnabled()) {
log.debug("Unable to resolve artifact: " + artifactName, e);
} else {
log.warn("Unable to resolve artifact: " + artifactName);
}
}
return null;
} finally {
if (sessionChecks != null) {
session.getData().set(SESSION_CHECKS, sessionChecks);
}
}
}
Aggregations