Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: dependency appears in effective pom but not in dependency tree

Working on a multi-module project.

GrandParent
        \
         Parent
             \
             Child

GrandParent has rogue_1 module in its <dependencyManagement> section as provided !

Parent does NOT have rogue_1 in its pom.xml at all.

Child does NOT have rogue_1 as a direct dependency in its pom.xml.

However it includes several other projects some of which may include rogue_1. (at least one does depend on rogue_1)

To be on the safe side, on ALL Child's dependencies I have added exclusions as follows:

<dependency> <!-- a direct dependency of Child -->
    <groupId>erso</groupId>
    <artifactId>galen</artifactId>
    <exclusions>
        <exclusion>
            <groupId>resistance</groupId>
            <artifactId>rogue_1</artifactId>
        </exclusion>
    </exclusions>
</dependency>

(in case for example galen.erso is bringing in the resistance.rogue_1)

However: rogue_1 DOES end up being displayed as a dependency in the outcome of

mvn help:effective-pom

(as provided !)

It is NOT in the ouctome of

mvn dependency:tree

Any suggestions?

like image 349
pkaramol Avatar asked Mar 07 '17 16:03

pkaramol


People also ask

What is difference between effective POM and POM xml?

you don't have to customize else as the other configurations will be inherited form the Super POM. The Effective POM refers the merge between the Super POM and the POM from The Simplest POM. It's right time to invest in Cryptocurrencies Dogecoin !

What is mvn dependency tree?

A project's dependency tree can be filtered to locate specific dependencies. For example, to find out why Velocity is being used by the Maven Dependency Plugin, we can execute the following in the project's directory: mvn dependency:tree -Dincludes=velocity:velocity.


1 Answers

mvn help:effective-pom

is basically a merger between the super POM (grand /+parent) dependencies and the simple POM that you defined at the project level. Hence you do see the rogue_1 under the XML created by effective-pom, of course your grandparent pom's dependencyManagement being the source. Here is a detailed read over the same.

mvn dependency:tree

on the other hand displays the tre of the dependencies used in your project. As you mentioned you've excluded this out of all your mentioned dependencies, so you shouldn't find the artifact listed here.

By the way, in both the cases the chances of having the rogue_1 in the classpath of your child module is zero.

like image 156
Naman Avatar answered Oct 06 '22 02:10

Naman