maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Beirtí Ó'Nunáin (JIRA) <j...@apache.org>
Subject [jira] [Commented] (MSHARED-466) Filtering dependencies does not retain the order of the unfiltered list
Date Tue, 24 Nov 2015 13:56:11 GMT

    [ https://issues.apache.org/jira/browse/MSHARED-466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15024552#comment-15024552
] 

Beirtí Ó'Nunáin commented on MSHARED-466:
-----------------------------------------

I originally raised this against the MDEP jira but it doesn't seem to have gotten any attention.
Here is the patch I have used locally to remedy the issue.

Index: AbstractArtifactFeatureFilter.java
===================================================================
— AbstractArtifactFeatureFilter.java (revision 1701613)
+++ AbstractArtifactFeatureFilter.java (working copy)
@@ -20,7 +20,7 @@
*/
import java.util.Arrays;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -83,7 +83,7 @@
*/
private Set filterIncludes( Set artifacts, List theIncludes )
{
Set result = new HashSet();
+ Set result = new LinkedHashSet();
Iterator includeIter = theIncludes.iterator();
while ( includeIter.hasNext() )
@@ -116,7 +116,7 @@
*/
private Set filterExcludes( Set artifacts, List theExcludes )
{
Set result = new HashSet();
+ Set result = new LinkedHashSet();
Iterator iter = artifacts.iterator();
while ( iter.hasNext() )

> Filtering dependencies does not retain the order of the unfiltered list
> -----------------------------------------------------------------------
>
>                 Key: MSHARED-466
>                 URL: https://issues.apache.org/jira/browse/MSHARED-466
>             Project: Maven Shared Components
>          Issue Type: Bug
>    Affects Versions: maven-common-artifact-filters-1.4
>            Reporter: Beirtí Ó'Nunáin
>
> If you use the dependency:build-classpath mojo, you get the dependency list as specified
in the pom. However, if you introduce filtering, you end up losing the dependency order. It
seems that the org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter declares
'Set' instead of 'SortedSet' and that the org.apache.maven.shared.artifact.filter.collection.AbstractArtifactFeatureFilter
returns a HashSet instead of a LinkedHashSet, even though a LinkedHashSet is being passed
in.
> The impact of this is that you cannot generate a correctly-ordered classpath when using
filters. The fix is very straightforward, simply change the filterIncludes and filterExcludes
methods of AbstractArtifactFeatureFilter to use a LinkedHashSet.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message