How to get all maven dependencies using ether?

I am trying to find maven artifact dependencies using ether. I see RepositorySystem.collectDependencies (), but selects only merge areas and runtimes. How to get all dependencies for an artifact, including validation and provisioning?

+4
source share
5 answers

Take a look at jcabi-aether (I'm a developer), which is a wrapper around Sonatype's ether:

File repo = this.session.getLocalRepository().getBasedir(); Collection<Artifact> deps = new Aether(this.getProject(), repo).resolve( new DefaultArtifact("junit", "junit-dep", "", "jar", "4.10"), JavaScopes.RUNTIME ); 
+2
source

Assuming you are using DefaultRepositorySystemSession , you can do the following:

 defaultRepositorySystemSession.setDependencySelector(new DependencySelector() { @Override public boolean selectDependency(Dependency dependency) { return true; } @Override public DependencySelector deriveChildSelector(DependencyCollectionContext context) { return this; } }); 

and then

 CollectResult result = repositorySystem.collectDependencies(defaultRepositorySystemSession, request); 

Here is an example project that does this.

+2
source

These three files:

https://github.com/terraframe/Runway-SDK/tree/v1.8.0/runwaysdk-server/src/main/java/com/runwaysdk/business/generation/maven

It is a working, stand-alone, example of the use of Aether.

This worked for several months, after which I suddenly had a problem when the DependencyResolutionException in com.sun: tools.jar was sometimes thrown on the Mac JRE.

Good luck, if you decide to use it, I will use maven-dependency-plugin dependency:build-classpath instead.

+1
source

You can use DependencyFilter on the air of Eclipses. The full version for the sample below can be found in this amazing set of Ether Snippets.

 DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE, JavaScopes.PROVIDED); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot( new Dependency( artifact, JavaScopes.COMPILE ) ); collectRequest.setRepositories(repositories); DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, classpathFilter ); List<ArtifactResult> artifactResults = system.resolveDependencies( session, dependencyRequest ).getArtifactResults(); 

UPDATE

Version 0.9.0M3 is not compatible with Maven 3.1.0, so do not use it inside Maven, i.e. in the plugin.

+1
source

Take a look at this github project: https://github.com/Gemba/mvn-dd
It downloads all the dependencies, including validation and provisioning.
He uses the ether library to get them.

+1
source

All Articles