mavendependency-managementtransitive-dependency

Excluding transitive dependency from Maven pom


I have a Maven dependency added where type is test-jar and scope is test. I want to remove a transitive dependency from this (because in the Nexus prod repo this dependency is missing which leads to Jenkins build failure). I have added a exclusion tag but still the dependency is not removed i.e. Jenkins build still fails and complains about this dependency. Any clue why?

    <dependency>
        <groupId>com.xxx</groupId>
        <artifactId>xxx</artifactId>
        <type>test-jar</type>
        <version>${xxx.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>jamon</artifactId>
                <groupId>com.jamonapi</groupId>
                <!-- <scope>compile</scope> -->
            </exclusion>
        </exclusions>
    </dependency>

Solution

  • You can use the following command to find out the transitive dependency details and then you can exclude the dependency:

    mvn dependency:tree -Dverbose -Dincludes=<artifact_name>