return runtime(dependencies.getDependencies());
.setResolutionFilter(ignoreProjectDependenciesFilter)); resolutionResult .getDependencies() .stream() .map(org.eclipse.aether.graph.Dependency::getArtifact)
protected List<File> resolveArtifacts(MavenProject mavenProject, Collection<String> scopes, DependencyFilter filter) throws MojoExecutionException { try { DefaultDependencyResolutionRequest request = new DefaultDependencyResolutionRequest(mavenProject, repoSession); if(filter != null) { request.setResolutionFilter(new AndDependencyFilter(new ScopeDependencyFilter(scopes, Collections.<String>emptyList()), filter)); } else { request.setResolutionFilter(new ScopeDependencyFilter(scopes, Collections.<String>emptyList())); } DependencyResolutionResult result = projectDependenciesResolver.resolve(request); List<org.eclipse.aether.graph.Dependency> dependencies = result.getDependencies(); final List<File> files = new ArrayList<File>(); for(org.eclipse.aether.graph.Dependency d : dependencies) { org.eclipse.aether.artifact.Artifact artifact = d.getArtifact(); File file = artifact.getFile(); if(file != null) { String name = file.getName(); if(!name.contains("xml-apis") && !name.contains("commons-logging")) files.add(file); } } return files; } catch (DependencyResolutionException e) { throw new MojoExecutionException("Dependency resolution failure: " + e.getMessage(), e); } }
@Override public List<Dependency> getEffectiveDependencies() { List<Dependency> result = new ArrayList<>(); MavenFacetImpl maven = getFaceted().getFacet(MavenFacetImpl.class); try { ProjectBuildingResult projectBuildingResult = maven.getProjectBuildingResult(); DependencyResolutionResult dependencyResolutionResult = projectBuildingResult.getDependencyResolutionResult(); List<Dependency> deps = MavenDependencyAdapter.fromAetherList(dependencyResolutionResult.getDependencies()); for (Dependency dependency : deps) { result.add(resolveProperties(dependency)); } } catch (Exception e) { log.log(Level.SEVERE, "Could not resolve managed dependencies in project [" + maven.getModelResource().getFullyQualifiedName() + "]. ", e); } return result; }
/** * When a DependencyResolutionResult event occurs during the build, the * event dependencies are recorded to the build-info.json file using Json * * @param event * DependencyResolutionResult a dependency resolution event * * @throws Exception */ public void onEvent(final DependencyResolutionResult event) throws Exception { final List<Dependency> dependencies = event.getDependencies(); logger.debug("onEvent(DependencyResolutionResult): " + event.getClass().getName() + "::" + event); logger.debug("Dependencies #: " + dependencies.size()); final List<BuildDependency> projectDependencies = new ArrayList<BuildDependency>(); for (final Dependency d : dependencies) { final BuildDependency currentDependency = new BuildDependency(); final Artifact artifact = d.getArtifact(); currentDependency.setGroup(artifact.getGroupId()); currentDependency.setArtifact(artifact.getArtifactId()); currentDependency.setVersion(artifact.getVersion()); final ArrayList<String> scopes = new ArrayList<String>(); scopes.add(d.getScope()); currentDependency.setScope(scopes); currentDependency.setClassifier(artifact.getClassifier()); currentDependency.setExtension(artifact.getExtension()); projectDependencies.add(currentDependency); } buildInfo.addDependencies(projectDependencies); }
List<Dependency> output = runtime(dependencies.getDependencies()); if (log.isInfoEnabled()) { for (Dependency dependency : output) {
throw new IllegalArgumentException(); dependencies.addAll(result.getDependencyResolutionResult().getDependencies());