public List<DependencyDescriptor> getArtifactDependecies( String artifactName ) { Artifact artifact = new DefaultArtifact( artifactName ); CollectRequest collectRequest = new CollectRequest(); Dependency root = new Dependency( artifact, "" ); collectRequest.setRoot( root ); for ( RemoteRepository repo : remoteRepositoriesForRequest ) { collectRequest.addRepository( repo ); } CollectResult collectResult; try { collectResult = aether.getSystem().collectDependencies( aether.getSession(), collectRequest ); } catch ( DependencyCollectionException e ) { throw new RuntimeException( e ); } CollectDependencyVisitor visitor = new CollectDependencyVisitor(); collectResult.getRoot().accept( visitor ); List<DependencyDescriptor> descriptors = new ArrayList<DependencyDescriptor>(); for ( DependencyNode node : visitor.getDependencies() ) { // skip root to not add artifact as dependency if ( node.getDependency().equals( root ) ) { continue; } descriptors.add( new DependencyDescriptor( node.getDependency().getArtifact() ) ); } return descriptors; }
public List<DependencyDescriptor> getArtifactDependecies( String artifactName ) { Artifact artifact = new DefaultArtifact( artifactName ); CollectRequest collectRequest = new CollectRequest(); Dependency root = new Dependency( artifact, "" ); collectRequest.setRoot( root ); for ( RemoteRepository repo : remoteRepositoriesForRequest ) { collectRequest.addRepository( repo ); } CollectResult collectResult; try { collectResult = aether.getSystem().collectDependencies( aether.getSession(), collectRequest ); } catch ( DependencyCollectionException e ) { throw new RuntimeException( e ); } CollectDependencyVisitor visitor = new CollectDependencyVisitor(); collectResult.getRoot().accept( visitor ); List<DependencyDescriptor> descriptors = new ArrayList<DependencyDescriptor>(); for ( DependencyNode node : visitor.getDependencies() ) { // skip root to not add artifact as dependency if ( node.getDependency().equals( root ) ) { continue; } descriptors.add( new DependencyDescriptor( node.getDependency().getArtifact() ) ); } return descriptors; }