Maven
  1. Maven
  2. MNG-3832

Allow wildcards in dependency exclusions

    Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.2.1
    • Component/s: Dependencies
    • Labels:
      None
    • 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
          Haakon Nilsen added a comment - - edited

          Not sure what's going on, but this seems to work in Maven 3.0.3, using this:

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

          However, this produces these warnings:

          [WARNING] 'dependencies.dependency.exclusions.exclusion.groupId' for my.groupid:my.artifactid:ejb-client with value '*' does not match a valid id pattern. @ line 31, column 30
          [WARNING] 'dependencies.dependency.exclusions.exclusion.artifactId' for my.groupid:my.artifactid:ejb-client with value '*' does not match a valid id pattern. @ line 32, column 33

          So I probably shouldn't be doing it, but it does work.

          Show
          Haakon Nilsen added a comment - - edited Not sure what's going on, but this seems to work in Maven 3.0.3, using this: <exclusion> <groupId>*</groupId> <artifactId>*</artifactId> </exclusion> However, this produces these warnings: [WARNING] 'dependencies.dependency.exclusions.exclusion.groupId' for my.groupid:my.artifactid:ejb-client with value '*' does not match a valid id pattern. @ line 31, column 30 [WARNING] 'dependencies.dependency.exclusions.exclusion.artifactId' for my.groupid:my.artifactid:ejb-client with value '*' does not match a valid id pattern. @ line 32, column 33 So I probably shouldn't be doing it, but it does work.
          Hide
          Matt Yates added a comment -

          This gentleman (Jos Dirksen) figured out what's going on and describes it on his blog
          In short, the above discussed ExcludesArtifactFilter is not even called (at least in Maven 3)
          Exclusions checks are instead made by ExclusionDependencySelector which handles the wildcard cases
          Basically, the only thing the needs to happen now is clean up of the warnings you get when you try to do this

          Show
          Matt Yates added a comment - This gentleman (Jos Dirksen) figured out what's going on and describes it on his blog In short, the above discussed ExcludesArtifactFilter is not even called (at least in Maven 3) Exclusions checks are instead made by ExclusionDependencySelector which handles the wildcard cases Basically, the only thing the needs to happen now is clean up of the warnings you get when you try to do this
          Hide
          Robert Scholte added a comment -

          Exclusion with wildcards already supported since Maven 3.0
          Warning fixed in http://git-wip-us.apache.org/repos/asf/maven/diff/65c135d5

          Show
          Robert Scholte added a comment - Exclusion with wildcards already supported since Maven 3.0 Warning fixed in http://git-wip-us.apache.org/repos/asf/maven/diff/65c135d5
          Hide
          Paul Benedict added a comment -

          Just for posterity, such configuration is already documented. See the "Exclusions" section:
          http://maven.apache.org/pom.html

          Show
          Paul Benedict added a comment - Just for posterity, such configuration is already documented. See the "Exclusions" section: http://maven.apache.org/pom.html
          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.

            People

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

              Dates

              • Created:
                Updated:
                Resolved: