【问题标题】:Is there a Maven plugin that shows the dependency tree of a plugin?是否有显示插件依赖树的 Maven 插件?
【发布时间】:2016-11-23 20:04:21
【问题描述】:

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

【问题讨论】:

标签: maven maven-3 maven-dependency-plugin


【解决方案1】:

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

<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>

【讨论】:

    【解决方案2】:

    您仍然可以将其添加为项目的依赖项,然后将其依赖关系树作为任何其他 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 属性缩小其输出范围是必需的。

    【讨论】:

    • 一个巧妙的技巧!虽然......如果你这样做,你也应该更好地使用-Dverbose=true(因为项目的一些依赖我会导致插件的依赖在​​依赖树中被替换)。不是最优雅的解决方案,但我想它可以解决问题。
    • 另外,在我的示例中,我应该使用不同的插件作为依赖项:这里您使用依赖项插件检查依赖项插件的依赖项,这可能会破坏 Internet
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多