Embracing the Messiness in Search of Epic Solutions

Maven: Excluding All Transitive Dependencies

Posted

in

I have been using Maven 3.0.3 on my work machine since 2011 because that particular version was released in March that year. How time flies by…

Maven 3.2.1 was released exactly a month ago. One feature that immediately jumps out is the ability to exclude a dependency’s transitive dependencies in a very simple manner, which is incredibly sweet and tasty.

Instead of manually excluding each transitive dependency one by one, we can use * wildcard now. Here’s an example from the release note:-

<?xml version="1.0"?>
<dependencies>
  <dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-embedder</artifactId>
    <version>3.1.0</version>
    <exclusions>
      <exclusion>
        <groupId>*</groupId>
        <artifactId>*</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  ...
</dependencies>

Okay, I have made an executive decision here… that I’ll upgrade Maven on my work machine to this latest version.

Tags:

Comments

Leave a Reply