Issue Details (XML | Word | Printable)

Key: MNG-3832
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Paul Gier
Votes: 30
Watchers: 24
Operations

If you were logged in you would be able to see more operations.
Maven 2 & 3

Allow wildcards in dependency exclusions

Created: 11/Nov/08 08:39 AM   Updated: 31/Dec/09 12:35 AM
Return to search
Component/s: Dependencies
Affects Version/s: None
Fix Version/s: 3.1

Time Tracking:
Not Specified

File Attachments: 1. Text File MNG-3832-maven-artifact.patch (20 kB)

Issue Links:
Related
 

Complexity: Intermediate


 Description  « Hide

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>


Kyle Lebel added a comment - 04/Feb/09 02:13 PM

I would like to see this as well, any news on this topic?


Vincenzo Vitale added a comment - 01/Apr/09 04:55 AM

+1


Feargal Egan added a comment - 02/May/09 04:42 AM

I agree, this would be extremely helpful.


Tomek Bujok added a comment - 02/Jul/09 02:53 PM

I have been using and popularizing Maven since many yeras. This week I am on some kind vacations so I decided to spend a day coding and contribute a little bit. I wanted to implement a "wildcard dependency exclusions feature" (MNG-3832). I have never browsed the Maven source code before, but after getting acquinted with the project structure, running and debugging it from eclipse I found the potential class to change. It was ExcludesArtifactFilter in the maven-artifact project.
The fix version of the feature was 2.x -> so I have checked out the code from the newest 2.2.x branch, since the trunk folder contains 3.x version.

I wanted the modification to be self-contained thus I have only changed the ExcludesArtifactFilter class. I have also created a test case (ExcludesArtifactFilterTest) encompassing 21 unit tests which proves the correctnes of the implemented approach.

I have extended the requested functionality a little bit. Right now, filter constructs literal java regular expression for every pattern which is contained by the list passed to the filter constructor. Include method matches given artifact against all patterns. Since it is an exlcusion filter - if artifact is matched at least once it will not be included. Filter defines "*" (star) as a wild-card character - a character that may be substituted for any other character(s). It is implemented in such a way, that every occurrence of a "*" (star) in the exclusion pattern is replaced with the ".*" expression during the construction of the literal java regex. Exclusion pattern can contain wild-card character zero or more times in any place in the groupId or artifactId;

Patch file is included as an external file to this issue.

Examples:

DEFINITION:
<exclusion>
  <groupId>*</groupId>
</exclusion>
SEMANTICS: All artifacts are excluded.
LITERAL_JAVA_REGEX: .*:.* (optimized by excludeAll flag)

DEFINITION:
<exclusion>
  <artifactId>*</artifactId>
</exclusion>
SEMANTICS: All artifacts are excluded.
LITERAL_JAVA_REGEX: .*:.* (optimized by excludeAll flag)

DEFINITION:
<exclusion>
  <groupId>*</groupId>
  <artifactId>*</artifactId>
</exclusion>
SEMANTICS: All artifacts are excluded.
LITERAL_JAVA_REGEX: .*:.* (optimized by excludeAll flag)

DEFINITION:
<exclusion>
  <groupId>*</groupId>
  <artifactId>commons-lang</artifactId>
</exclusion>
SEMANTICS: Artifacts with any groupId and with the artifactId equal to "commons-lang" will be excluded.
LITERAL_JAVA_REGEX: .*:commons-lang

DEFINITION:
<exclusion>
  <groupId>org.springframework</groupId>
  <artifactId>*</artifactId>
</exclusion>
SEMANTICS: Artifacts with groupId "org.springframework" will be excluded.
LITERAL_JAVA_REGEX: org\.springframework:.*
MATCHING_ARTIFACT_EXAMPLES: org.springframework:spring-ws
NOT_MATCHING_ARTIFACT_EXAMPLES: org.springframework.snapshot:spring-ws

DEFINITION:
<exclusion>
  <groupId>org.springframework.*</groupId>
  <artifactId>*</artifactId>
</exclusion>
SEMANTICS: Artifacts with groupId beginning with "org.springframework." will be excluded.
LITERAL_JAVA_REGEX: org\.springframework\..*:.*
MATCHING_ARTIFACT_EXAMPLES: org.springframework.snapshot:spring-ws
NOT_MATCHING_ARTIFACT_EXAMPLES: org.springframeworksnapshot:spring-ws

DEFINITION:
<exclusion>
  <groupId>org.springframework*</groupId>
  <artifactId>*</artifactId>
</exclusion>
SEMANTICS: Artifacts with groupId beginning with "org.springframework" will be excluded.
LITERAL_JAVA_REGEX: org\.springframework.*:.*
MATCHING_ARTIFACT_EXAMPLES: org.springframework.snapshot:spring-ws, org.springframeworksnapshot:spring-ws
NOT_MATCHING_ARTIFACT_EXAMPLES: org.spring.snapshot:spring-ws

DEFINITION:
<exclusion>
  <groupId>org.*.test</groupId>
  <artifactId>*</artifactId>
</exclusion>
SEMANTICS: Artifacts with groupId beginning with "org." and ending with ".test" will be excluded.
LITERAL_JAVA_REGEX: org\..*\.test*:.*
MATCHING_ARTIFACT_EXAMPLES: org.apache.test:test-library, org.apache.snapshot.test:test-library
NOT_MATCHING_ARTIFACT_EXAMPLES: orgapachetest:test-library

Tomek Bujok added a comment - 02/Jul/09 02:55 PM

Patch which solves MNG-3832 issue (also including test case)


Tomek Bujok added a comment - 03/Nov/09 08:38 AM

Was this patch helpful to you? Or maybe you are not interested in such contribution? I was delighted to implement this feature and right now I am little bit dissapointed that there is no activity in this subject.


Tomek Bujok added a comment - 13/Nov/09 08:51 AM

The solution I have implemented could be easily included to 2.2.2 version. Many people urgently require this feature (There are 16 votes here and 74 in MNG-2315) Is the approach that I implemented inline with the Maven2 architecture? I can implement it once more or correct the patch in order to have this ticket resolved in 2.2.2 version.


Wendy Smoak added a comment - 13/Nov/09 09:04 AM

I think you'll get more attention if you post to the dev list and describe what you've done. JIRA produces a LOT of mail and many people filter it out. This is an issue with quite a few votes and watchers, so hopefully you'll catch the interest of a committer who can help.


Brett Porter added a comment - 31/Dec/09 12:35 AM

there's a few exclusions issues in the 3.1 bucket we can pull together