use of org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException in project maven-plugins by apache.
the class DefaultDependencyResolver method resolveNonTransitively.
Set<Artifact> resolveNonTransitively(final Assembly assembly, final Set<Artifact> dependencyArtifacts, final AssemblerConfigurationSource configSource, final List<ArtifactRepository> repos) throws DependencyResolutionException {
final List<Artifact> missing = new ArrayList<Artifact>();
final Set<Artifact> resolved = new LinkedHashSet<Artifact>();
for (final Artifact depArtifact : dependencyArtifacts) {
ArtifactResolutionRequest req = new ArtifactResolutionRequest();
req.setLocalRepository(configSource.getLocalRepository());
req.setRemoteRepositories(repos);
req.setArtifact(depArtifact);
ArtifactResolutionResult resolve = resolver.resolve(req);
if (resolve.hasExceptions()) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Failed to resolve: " + depArtifact.getId() + " for assembly: " + assembly.getId());
}
missing.add(depArtifact);
} else {
resolved.add(depArtifact);
}
}
if (!missing.isEmpty()) {
final MavenProject project = configSource.getProject();
final Artifact rootArtifact = project.getArtifact();
final Throwable error = new MultipleArtifactsNotFoundException(rootArtifact, new ArrayList<Artifact>(resolved), missing, repos);
throw new DependencyResolutionException("Failed to resolve dependencies for: " + assembly.getId(), error);
}
return resolved;
}
Aggregations