Maven
  1. Maven
  2. MNG-3832

Allow wildcards in dependency exclusions

    Details

    • Complexity:
      Intermediate
    • Number of attachments :
      1

      Description

      I would like to be able to exclude all transitive dependencies from a certain dependencies. This is especially useful when depending on an artifact with a classifier that may not have the same dependencies as the main artifact. Currently the only way to do this is by excluding each dependency individually which requires significant effort and is prone to becoming out of date. The following syntax is one possibility.

      Exclude all transitive dependencies

      <exclusion>
        <groupId>*</groupId>
      </exclusion>
      

      Exclude transitive dependencies with the groupId "org.company"

      <exclusion>
        <groupId>org.company</groupId>
        <artifactId>*</artifactId>
      </exclusion>
      

        Issue Links

          Activity

          Hide
          Ciprian Pascu added a comment -

          This feature does not work with maven-dependency-plugin.
          Also Idea development environment is affected.

          Show
          Ciprian Pascu added a comment - This feature does not work with maven-dependency-plugin. Also Idea development environment is affected.
          Hide
          Denis Tunovic added a comment -

          Same here as comment from Ciprian with Maven 3.2.2

          Show
          Denis Tunovic added a comment - Same here as comment from Ciprian with Maven 3.2.2
          Hide
          Sergei Ivanov added a comment -

          Denis/Ciprian: it would be beneficial if you attached a small test project + a more detailed explanation to demonstrate the problem.

          Show
          Sergei Ivanov added a comment - Denis/Ciprian: it would be beneficial if you attached a small test project + a more detailed explanation to demonstrate the problem.
          Hide
          Ciprian Pascu added a comment -

          Sorry for writing so late Sergei,

          The scenario is simple:
          Create a pom file. Add a dependency with transitive dependencies. For example axis 2 dependency.
          From command line execute mvn dependency:tree -Dverbose=true
          The entire tree is visible.
          Add exclusion with * to axis 2 dependency.
          From command line execute again mvn dependency:tree -Dverbose=true
          The entire tree is visible. But it shouldn't.

          Show
          Ciprian Pascu added a comment - Sorry for writing so late Sergei, The scenario is simple: Create a pom file. Add a dependency with transitive dependencies. For example axis 2 dependency. From command line execute mvn dependency:tree -Dverbose=true The entire tree is visible. Add exclusion with * to axis 2 dependency. From command line execute again mvn dependency:tree -Dverbose=true The entire tree is visible. But it shouldn't.
          Hide
          Robert Scholte added a comment -

          Ciprian Pascu, you're facing an issue with the maven-dependency-plugin, not with Maven Core. Ensure you're using the latest version:

          mvn org.apache.maven.plugins:maven-dependency-plugin:2.9:tree -Dverbose=true
          

          If that still shows the wrong tree, create an issue for the maven-dependency-plugin.
          To ensure that excludes works, run mvn compile -X, which will show the actual project jars used by Maven.

          Show
          Robert Scholte added a comment - Ciprian Pascu , you're facing an issue with the maven-dependency-plugin , not with Maven Core. Ensure you're using the latest version: mvn org.apache.maven.plugins:maven-dependency-plugin:2.9:tree -Dverbose=true If that still shows the wrong tree, create an issue for the maven-dependency-plugin. To ensure that excludes works, run mvn compile -X , which will show the actual project jars used by Maven.

            People

            • Assignee:
              Robert Scholte
              Reporter:
              Paul Gier
            • Votes:
              75 Vote for this issue
              Watchers:
              69 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: