use of org.apache.maven.project.DependencyResolutionResult in project che by eclipse.
the class MavenServerImpl method createResult.
private MavenServerResult createResult(File pom, MavenResult mavenResult) throws RemoteException {
List<MavenProjectProblem> problems = new ArrayList<>();
Set<MavenKey> unresolvedArtifacts = new HashSet<>();
validate(pom, mavenResult.getExceptions(), problems);
MavenProject project = mavenResult.getMavenProject();
if (project == null) {
return new MavenServerResult(null, problems, unresolvedArtifacts);
}
MavenModel model = null;
try {
DependencyResolutionResult resolutionResult = mavenResult.getDependencyResolutionResult();
org.eclipse.aether.graph.DependencyNode dependencyNode = null;
if (resolutionResult != null) {
dependencyNode = resolutionResult.getDependencyGraph();
}
List<org.eclipse.aether.graph.DependencyNode> dependencyNodes = null;
if (dependencyNode != null) {
dependencyNodes = dependencyNode.getChildren();
}
model = MavenModelUtil.convertProjectToModel(project, dependencyNodes, new File(localRepo.getBasedir()));
} catch (Exception e) {
validate(project.getFile(), Collections.singletonList(e), problems);
}
List<String> activeProfiles = getActiveProfiles(project);
MavenProjectInfo projectInfo = new MavenProjectInfo(model, null, activeProfiles);
return new MavenServerResult(projectInfo, problems, unresolvedArtifacts);
}
use of org.apache.maven.project.DependencyResolutionResult 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