use of org.apache.maven.artifact.repository.ArtifactRepository in project bnd by bndtools.
the class DependencyResolver method resolve.
public Map<File, ArtifactResult> resolve() throws MojoExecutionException {
if (resolvedDependencies != null) {
return resolvedDependencies;
}
DependencyResolutionRequest request = new DefaultDependencyResolutionRequest(project, session);
request.setResolutionFilter(new DependencyFilter() {
@Override
public boolean accept(DependencyNode node, List<DependencyNode> parents) {
if (node.getDependency() != null) {
return scopes.contains(node.getDependency().getScope());
}
return false;
}
});
DependencyResolutionResult result;
try {
result = resolver.resolve(request);
} catch (DependencyResolutionException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
Map<File, ArtifactResult> dependencies = new HashMap<>();
DependencyNode dependencyGraph = result.getDependencyGraph();
if (dependencyGraph != null && !dependencyGraph.getChildren().isEmpty()) {
List<RemoteRepository> remoteRepositories = new ArrayList<>(project.getRemoteProjectRepositories());
ArtifactRepository deployRepo = project.getDistributionManagementArtifactRepository();
if (deployRepo != null) {
remoteRepositories.add(RepositoryUtils.toRepo(deployRepo));
}
discoverArtifacts(dependencies, dependencyGraph.getChildren(), project.getArtifact().getId(), remoteRepositories);
}
return resolvedDependencies = dependencies;
}
Aggregations