CPD Results

The following document contains the results of PMD's CPD 5.6.1.

Duplications

File Line
org\apache\maven\shared\artifact\filter\resolve\transform\EclipseAetherFilterTransformer.java 84
org\apache\maven\shared\artifact\filter\resolve\transform\SonatypeAetherFilterTransformer.java 84
            filters.add( filter.transform( this ) );
        }
        return new OrDependencyFilter( filters );
    }

    @Override
    public ScopeDependencyFilter transform( ScopeFilter filter )
    {
        return new ScopeDependencyFilter( filter.getIncluded(), filter.getExcluded() );
    }
    
    @Override
    public DependencyFilter transform( PatternExclusionsFilter filter )
    {
        return new PatternExclusionsDependencyFilter( filter.getExcludes() );
    } 

    @Override
    public DependencyFilter transform( PatternInclusionsFilter filter )
    {
        // if any include contains a classifier:
        // split all includes and make it an or-filter for every include
        // for the classifier, add an and-filter with a classifierfilter and patterninclusionfilter
        
        for ( String include : filter.getIncludes() )
        {
            if ( include.matches( GAE_C_V ) )
            {
                return newAdvancedPatternInclusionFilter( filter.getIncludes() );
            }
        }
        
        return new PatternInclusionsDependencyFilter( filter.getIncludes() );
    }
    
    @Override
    public DependencyFilter transform( final AbstractFilter filter )
    {
        return new DependencyFilter()
        {
            @Override
            public boolean accept( DependencyNode node, List<DependencyNode> parents )
            {
                return filter.accept( new EclipseAetherNode( node ), null );
File Line
org\apache\maven\shared\artifact\filter\resolve\transform\EclipseAetherNode.java 42
org\apache\maven\shared\artifact\filter\resolve\transform\SonatypeAetherNode.java 42
    EclipseAetherNode( DependencyNode node )
    {
        this.node = node;
    }

    @Override
    public org.apache.maven.model.Dependency getDependency()
    {
        Dependency nodeDependency = node.getDependency();

        if ( nodeDependency == null )
        {
            return null;
        }

        org.apache.maven.model.Dependency mavenDependency = new org.apache.maven.model.Dependency();
        mavenDependency.setGroupId( nodeDependency.getArtifact().getGroupId() );
        mavenDependency.setArtifactId( nodeDependency.getArtifact().getArtifactId() );
        mavenDependency.setVersion( nodeDependency.getArtifact().getVersion() );
        mavenDependency.setClassifier( nodeDependency.getArtifact().getClassifier() );
        mavenDependency.setType( nodeDependency.getArtifact().getProperty( ArtifactProperties.TYPE, null ) );
        mavenDependency.setScope( nodeDependency.getScope() );
File Line
org\apache\maven\shared\artifact\filter\resolve\transform\EclipseAetherFilterTransformer.java 127
org\apache\maven\shared\artifact\filter\resolve\transform\SonatypeAetherFilterTransformer.java 127
                return filter.accept( new EclipseAetherNode( node ), null );
            }
        }; 
    }

    private DependencyFilter newAdvancedPatternInclusionFilter( Collection<String> includes )
    {
        List<DependencyFilter> filters = new ArrayList<DependencyFilter>( includes.size() );

        Pattern pattern = Pattern.compile( GAE_C_V );
        for ( String include : includes )
        {
            Matcher matcher = pattern.matcher( include );
            if ( matcher.matches() )
            {
                DependencyFilter patternFilter =
                    new PatternInclusionsDependencyFilter( matcher.group( 1 ) + matcher.group( 3 ) );

                final String classifier = matcher.group( 2 );
                
                DependencyFilter classifierFilter = new DependencyFilter()
                {
                    @Override
                    public boolean accept( DependencyNode node, List<DependencyNode> parents )
                    {
                        String nodeClassifier = node.getArtifact().getClassifier();
File Line
org\apache\maven\shared\artifact\filter\resolve\transform\EclipseAetherNode.java 69
org\apache\maven\shared\artifact\filter\resolve\transform\SonatypeAetherNode.java 66
        if ( nodeDependency.getExclusions() != null )
        {
            List<org.apache.maven.model.Exclusion> mavenExclusions =
                new ArrayList<org.apache.maven.model.Exclusion>( nodeDependency.getExclusions().size() );

            for ( Exclusion aetherExclusion : nodeDependency.getExclusions() )
            {
                org.apache.maven.model.Exclusion mavenExclusion = new org.apache.maven.model.Exclusion();

                mavenExclusion.setGroupId( aetherExclusion.getGroupId() );
                mavenExclusion.setArtifactId( aetherExclusion.getArtifactId() );
                // that's all folks, although Aether has more metadata

                mavenExclusions.add( mavenExclusion );
            }

            mavenDependency.setExclusions( mavenExclusions );
        }

        return mavenDependency;
    }
     
}