Maven 2.1 dependency: analysis. Transitive dependencies: undeclared dependencies found

I use dependency:analyze to detect dependency problems. But I found a problem with transitive dependencies, because the plugin does not resolve these dependencies.

When I execute mvn dependency: tree, the output shows transitive dependencies.

Dependencies

 project A dependency B project C dependency A 

Outuput -> (project C - path) / mvn clean install

 [WARNING] Used undeclared dependencies found: dependency B: compile 

Plugin

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

Why the plugin does not detect a transitive dependency

+6
source share
1 answer

Dependency analysis works as expected.

The code in project C uses the classes from project B, but it does not directly depend on project B. It is compiled only because it depends on B through project A. Changing the dependency of project A will break the project C. This is what we are trying to avoid

This is bad if the code uses classes from B, it should directly depend on B.

+5
source

Source: https://habr.com/ru/post/949591/


All Articles