分析dependency的依赖作为一个pom

Analyzing dependency of dependency as a pom

假设我们创建了一个项目,它是一种库项目(一个项目聚合了依赖项)。


    <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.packt</groupId>
      <artifactId>axis2-client</artifactId>
      <version>1.0.0</version>
      <packaging>pom</packaging>
      <dependencies>
        <dependency>
          <groupId>org.apache.axis2</groupId>
          <artifactId>axis2-kernel</artifactId>
          <version>1.6.2</version>
        </dependency>
        <dependency>
          <groupId>org.apache.axis2</groupId>
          <artifactId>axis2-adb</artifactId>
          <version>1.6.2</version>
        </dependency>
        <dependency>
          <groupId>org.apache.axis2</groupId>
          <artifactId>axis2-transport-http</artifactId>
          <version>1.6.2</version>
        </dependency>
        <dependency>
          <groupId>org.apache.axis2</groupId>
          <artifactId>axis2-transport-local</artifactId>
          <version>1.6.2</version>
        </dependency>
        <dependency>
          <groupId>org.apache.axis2</groupId>
          <artifactId>axis2-xmlbeans</artifactId>
          <version>1.6.2</version>
        </dependency>
      </dependencies>
    </project>

另一个项目正在使用库项目作为依赖项。


    <project>
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.packt</groupId>
      <artifactId>my-axis2-client</artifactId>
      <version>1.0.0</version>

      <dependencies>
        <dependency>
          <groupId>com.packt</groupId>
          <artifactId>axis2-client</artifactId>
          <version>1.0.0</version>
          <type>pom<type>
        </dependency>
      </dependencies>
    </project>

我认为这个用例假设 my-axis2-client 使用 axis2-client 中的依赖项作为直接依赖项。 所以这意味着我可以在 my-axis2-client 中使用 org.apache.axis2.client.ServiceClient(in axis2-kernel-1.6.2.jar) class。 但是,当我 运行 mvn dependency:anlyze 时,它会生成以下结果。


    [WARNING] Used undeclared dependencies found:
    [WARNING]     org.apache.axis2:axis2-kernal:jar:1.6.2:compile
    [WARNING] Unused declared dependencies found:
    [WARNING]     compackt:axis2-client:pom:1.0.0:compile

我认为这不是一个有效的警告。 如果有任何方法可以分析这种情况下的依赖关系,请告诉我。

在您的构造中,生成的依赖关系是可传递的,而不是直接的。您依赖于 POM,而 POM 本身又依赖于罐子。