是否有显示插件依赖树的 Maven 插件?

Is there a Maven plugin that shows the dependency tree of a plugin?

有没有更简单的方法来获取 Maven 插件的依赖关系树,而不是检查其源代码并 运行 mvn dependency:tree 针对它们?

这不是您想要的确切内容,但更接近于此,至少它会分析依赖关系并预先列出所有警告。

<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>Dependency-Analyzer</id>
            <phase>package</phase>
            <goals>
              <goal>analyze-only</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

无需检查相关插件的源代码,您仍然可以将其添加为项目的依赖项,然后检查其依赖项树作为任何其他 Maven 依赖项。

maven 插件毕竟是一个 jar 文件,可以作为任何其他 maven 依赖项添加(没有真正意义,除非在 maven 插件开发的上下文中)。

例如,我们可以将 maven-dependency-plugin 作为依赖项:

<dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.10</version>
    <scope>test</scope>
</dependency>

请注意 scope 的纯度,即使您可能会在必要的检查后从项目中删除依赖项。

现在您可以 运行 在这个项目上 dependency:tree 并检查这个插件的依赖性,通过 includes 属性 缩小它的输出是必需的。