excluded.removeAll( included ); return new ScopeDependencyFilter( null, excluded );
private List<Artifact> getArtifacts(String artifact) throws MojoExecutionException { Dependency dependency = new Dependency( new DefaultArtifact( artifact ), "runtime" ); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot( dependency ); //collectRequest.addRepository( remoteRepos ); DependencyNode node; try { node = repoSystem.collectDependencies( repoSession, collectRequest ).getRoot(); } catch (DependencyCollectionException e) { throw new MojoExecutionException( e.getMessage(), e ); } DependencyRequest dependencyRequest = new DependencyRequest( node, null ); Set<String> included = Collections.singleton("runtime"); dependencyRequest.setFilter(new ScopeDependencyFilter(included, Collections.EMPTY_SET)); try { repoSystem.resolveDependencies( repoSession, dependencyRequest ); } catch (DependencyResolutionException e) { throw new MojoExecutionException( e.getMessage(), e ); } PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); node.accept( nlg ); getLog().info( "" + nlg.getClassPath() ); return nlg.getArtifacts(false); }
DependencyNode node = repositorySystem.collectDependencies(session, request).getRoot(); repositorySystem.resolveDependencies(session, node, new ScopeDependencyFilter("test")); pomNode.getChildren().add(node);