Maven: Excluding All Transitive Dependencies

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s