How to get access to Maven's dependency hierarchy within a plugin

前端 未结 7 1667
生来不讨喜
生来不讨喜 2020-11-29 05:25

In my plugin I need to process the dependency hierarchy and get information (groupId, artifactId, version etc) about each dependency and if it was excluded. What is the best

7条回答
  •  情话喂你
    2020-11-29 05:43

    Try to use Aether utility class from jcabi-aether to get a list of all dependencies of any artifact:

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

提交回复
热议问题