I am trying to building a separate project which can find maven dependencies of any given project. I was referring Aether samples but i could not find a way to define another project to find dependencies.
As shown in the following figure 1, Project 1 has dependencies of project 2 and project 2 has dependencies of project 3. If i select project 1 on dependency finder it should show all the dependencies of project 1 which are project 2.
I was referring following Aether code piece but i could not figure out a way to set another project (by setting pom file or project directory)
RepositorySystem system = Booter.newRepositorySystem();
RepositorySystemSession session = Booter.newRepositorySystemSession( system );
Artifact artifact = new DefaultArtifact( "org.eclipse.aether:aether-impl:1.0.0.v20140518" );
ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
descriptorRequest.setArtifact( artifact );
descriptorRequest.setRepositories( Booter.newRepositories( system, session ) );
ArtifactDescriptorResult descriptorResult = system.readArtifactDescriptor( session, descriptorRequest );
for ( Dependency dependency : descriptorResult.getDependencies() )
{
System.out.println( dependency );
}
You don't need to do it programatically. You could simply invoke dependency:tree:
mvn dependency:tree
I would also recommend you invoke it with -Dverbose
in case you're really, really having a hard time figuring why a certain version of a dependency is being chosen over another one (which you may be expecting it to be using instead).
Or, alternatively, if you'd like to see the dependencies in a flat form, you could also use dependency:list
mvn dependency:list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With