Jav*_*era 6 java maven-2 maven maven-dependency-plugin
我正在使用它dependency:analyze来检测依赖性问题.但我发现传递依赖项存在问题,因为插件无法解析此依赖项.
当我执行mvn dependency:tree时,输出显示传递依赖项.
依赖
project A
dependency B
project C
dependency A
Run Code Online (Sandbox Code Playgroud)
Outuput - >(项目C - 路径)/ mvn clean install
[WARNING] Used undeclared dependencies found:
dependency B: compile
Run Code Online (Sandbox Code Playgroud)
插入
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>analyze</id>
<phase>verify</phase>
<goals>
<goal>analyze-only</goal>
</goals>
<configuration>
<failOnWarning>true</failOnWarning>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
为什么插件不会检测传递依赖性
依赖性分析按预期工作.
项目C中的代码使用项目B中的类,但它并不直接依赖于项目B.它只是因为它通过项目A过渡依赖于B而编译.更改项目A的依赖项会破坏项目C.这就是我们要避免的
这不好,如果代码使用来自B的类,它应该直接依赖于B.