[ 
http://jira.codehaus.org/browse/MSHARED-88?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=160966#action_160966
 ] 

Owen Kellett commented on MSHARED-88:
-------------------------------------

Update: Due to the possibility of null values for classifier and type, you need 
to account for this possibility.  I'm using the 
org.codehaus.plexus.util.StringUtils from the plexus-utils package in the 
update below:

{code:java}
public boolean artifactIsADirectDependency( Artifact artifact )
{
    boolean result = false;
    Iterator iterator = this.directDependencies.iterator();
    while ( iterator.hasNext() )
    {
        Artifact dependency = (Artifact) iterator.next();
        if ( StringUtils.equals(dependency.getGroupId(), artifact.getGroupId()) 
&&
             StringUtils.equals(dependency.getArtifactId(), 
artifact.getArtifactId()) &&
             StringUtils.equals(dependency.getClassifier(), 
artifact.getClassifier()) &&
             StringUtils.equals(dependency.getType(), artifact.getType())) {
        {
            result = true;
            break;
        }
    }
    return result;
}
{code}

> ProjectTransitivityFilter has incorrect behavior for 
> artifactIsADirectDependency method
> ---------------------------------------------------------------------------------------
>
>                 Key: MSHARED-88
>                 URL: http://jira.codehaus.org/browse/MSHARED-88
>             Project: Maven Shared Components
>          Issue Type: Bug
>          Components: maven-common-artifact-filters
>            Reporter: Owen Kellett
>            Priority: Minor
>
> In the class 
> org.apache.maven.shared.artifact.filter.collection.ProjectTransitivityFilter, 
> the filter should only include items that are part of the direct 
> dependencies.  However, the method that does this check 
> (artifactIsADirectDependency) only verifies that a dependency has the same 
> artifactId and groupId as a direct dependency.  It should also check the 
> classifier and type.  I've included an updated version of the method below:
> {code:java}
> public boolean artifactIsADirectDependency( Artifact artifact )
> {
>     boolean result = false;
>     Iterator iterator = this.directDependencies.iterator();
>     while ( iterator.hasNext() )
>     {
>         Artifact dependency = (Artifact) iterator.next();
>         if ( dependency.getGroupId().equals( artifact.getGroupId() ) &&
>             dependency.getArtifactId().equals( artifact.getArtifactId() ) &&
>             dependency.getClassifier().equals( artifact.getClassifier() ) &&
>             dependency.getType().equals( artifact.getType() ) )
>         {
>             result = true;
>             break;
>         }
>     }
>     return result;
> }
> {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

        

Reply via email to