Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven 2.1 dependency:analyze. Transitive dependencies: Used undeclared dependencies found

I am using the dependency:analyze to detect dependency problems. But I have found a problem with the transitive dependencies because the plugin doesn't resolve this dependencies.

When I execute mvn dependency:tree, the output shows the 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 doesn't detect the transitive dependency

like image 200
Javi Pedrera Avatar asked Jul 16 '13 19:07

Javi Pedrera


People also ask

Does Maven support transitive dependencies?

Transitive Dependencies. Maven avoids the need to discover and specify the libraries that your own dependencies require by including transitive dependencies automatically. This feature is facilitated by reading the project files of your dependencies from the remote repositories specified.

What is transitive dependency in Maven example?

Maven Dependency Tree Transitive dependency means that if A depends on B and B depends on C, then A depends on both B and C. Sometimes, transitivity brings a very serious problem when different versions of the same artifacts are included by different dependencies. It may cause version mismatch issues in runtime.

What does Maven dependency plugin do?

The dependency plugin provides the capability to manipulate artifacts. It can copy and/or unpack artifacts from local or remote repositories to a specified location.


1 Answers

Dependency analysis works as expected.

Code in project C uses classes from project B but it does not directly depend on project B. It compiles only because it transitively depend on B through project A. Changing dependency of project A would break project C. This is what we are trying to avoid

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

like image 84
Grzegorz Żur Avatar answered Oct 19 '22 22:10

Grzegorz Żur