Skip to content

Graph does not respect wildcard exclusions #76

@crosslandwa

Description

@crosslandwa

Hi - great tool, I've been finding it really useful understanding dependencies in some legacy apps I've been working on.

I've identified an issue where the generated dependency graph incorrectly shows dependencies that maven has excluded via a wildcard.

If I have an app, which depends on lib-b, which depends on lib-c:

app pom:

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.github.crosslandwa</groupId>
    <artifactId>mvndependencygraph-issue-app</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>
    <dependencies>
        <dependency>
            <groupId>com.github.crosslandwa</groupId>
            <artifactId>mvndependencygraph-issue-lib-b</artifactId>
            <version>1.0</version>
            <exclusions>
                <exclusion>
                    <groupId>com.github.crosslandwa</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
</project>

lib-b pom:

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.github.crosslandwa</groupId>
    <artifactId>mvndependencygraph-issue-lib-b</artifactId>
    <packaging>jar</packaging>
    <version>1.0</version>
    <dependencies>
        <dependency>
            <groupId>com.github.crosslandwa</groupId>
            <artifactId>mvndependencygraph-issue-lib-c</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
</project>

And I generate a graph via

mvn com.github.ferstl:depgraph-maven-plugin:graph -DcreateImage=true -DshowGroupIds=true -DshowVersions=true -DshowConflicts=true -DshowDuplicates=true

Expected:

The output for mvn dependency:tree

[INFO] --------< com.github.crosslandwa:mvndependencygraph-issue-app >---------
[INFO] Building mvndependencygraph-issue-app 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ mvndependencygraph-issue-app ---
[INFO] com.github.crosslandwa:mvndependencygraph-issue-app:jar:1.0
[INFO] \- com.github.crosslandwa:mvndependencygraph-issue-lib-b:jar:1.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

Which would have the expected graph of:

dependency-graph

Actual:

But I'm actually seeing...

dependency-graph

Note 1: explicitly defining an exclusion with a groupID works as expected, e.g.

<dependency>
    <groupId>com.github.crosslandwa</groupId>
    <artifactId>mvndependencygraph-issue-lib-b</artifactId>
    <version>1.0</version>
    <exclusions>
        <exclusion>
            <groupId>com.github.crosslandwa</groupId>
            <artifactId>mvndependencygraph-issue-lib-c</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Note 2: ommiting both the -DshowConflicts=true and -DshowDuplicates=true options also works correctly, i.e.

mvn com.github.ferstl:depgraph-maven-plugin:graph -DcreateImage=true -DshowGroupIds=true -DshowVersions=true

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions