Is it possible to get the dependency tree or list of dependencies of a given maven dependency using an API?
Asked
Active
Viewed 165 times
0
-
1Do you need this inside a Maven plugin or inside a Java program? – J Fabian Meier Mar 05 '20 at 09:51
-
Inside a Java Program – Pramodya Mendis Mar 05 '20 at 10:08
-
1Why do you need it inside a java program what kind of problem are you trying to solve? – khmarbaise Mar 05 '20 at 10:22
-
I want to download all the dependent packages of a given maven dependency (eg: `org.apache.commons.commons-lang3.3.9`) to a specific folder. Is there any API provided by Maven to do that? – Pramodya Mendis Mar 05 '20 at 11:03
-
Have you thought about just calling the maven dependency plugin? It is a command line call, but it is a direct way to achieve this. From Java, you could try to use Maven Resolver (Aether). – J Fabian Meier Mar 05 '20 at 11:43
-
Alright, So there is no such an API to achieve this directly? – Pramodya Mendis Mar 05 '20 at 11:44
-
1Maven Resolver is such an API, but I cannot provide you a concrete example. – J Fabian Meier Mar 05 '20 at 11:58
-
@JFMeier Can you please provide some kind of example or link? – Pramodya Mendis Mar 09 '20 at 12:20
-
https://stackoverflow.com/q/11799923/927493 – J Fabian Meier Mar 09 '20 at 14:53
-
@JFMeier Can you suggest to me a way that I can list down all the dependencies of a mvn project programmatically without using CLI? Can I use maven dependency plugin to do that? – Pramodya Mendis Mar 10 '20 at 14:23
-
Sorry to be so unspecific, but I know that you _can_ do such things with Maven Resolver or Aether (as it was called before). But I do not know any good source or tutorial for it. There are examples on Stackoverflow, scattered at various places. – J Fabian Meier Mar 10 '20 at 14:42
-
BTW: What is the reason you want to copy these dependencies? – J Fabian Meier Mar 10 '20 at 14:42