You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Tomek Bujok (JIRA)" <ji...@codehaus.org> on 2009/07/02 21:54:22 UTC

[jira] Commented: (MNG-3832) Allow wildcards in dependency exclusions

    [ http://jira.codehaus.org/browse/MNG-3832?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=182334#action_182334 ] 

Tomek Bujok commented on MNG-3832:
----------------------------------

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:

{code:xml} 
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
{code} 

> Allow wildcards in dependency exclusions
> ----------------------------------------
>
>                 Key: MNG-3832
>                 URL: http://jira.codehaus.org/browse/MNG-3832
>             Project: Maven 2
>          Issue Type: New Feature
>          Components: Dependencies
>            Reporter: Paul Gier
>             Fix For: 2.x
>
>
> 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
> {code}
> <exclusion>
>   <groupId>*</groupId>
> </exclusion>
> {code}
> Exclude transitive dependencies with the groupId "org.company"
> {code}
> <exclusion>
>   <groupId>org.company</groupId>
>   <artifactId>*</artifactId>
> </exclusion>
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira