Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all maven dependencies using aether?

Tags:

maven

aether

I'm trying to fetch a maven artifact's dependencies using aether. I see a RepositorySystem.collectDependencies(), but that fetches only compile and runtime scoped dependencies. How do I fetch all dependencies for the artifact, including test and provided?

like image 203
akula1001 Avatar asked Feb 17 '23 09:02

akula1001


1 Answers

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

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
);
like image 120
yegor256 Avatar answered Feb 28 '23 11:02

yegor256