Hi.

I think I found a defect in the latest currently available Maven Assembly
plugin version 3.3.0. The Assembly plugin uses Common Artifact Filters's
class `PatternIncludesArtifactFilter`. This class, in its method
`matchAgainst()` loops over include patterns. If one of the include
patterns contains 4+ components, 4th being the classifier (according to the
source code, documentation does not mention classifier), it immediately
rejects the artifact being checked for inclusion without testing the other
patterns. My inclusion patterns are

   - <include>com.XYZ:some-artifact:*:service:*</include>
   - <include>org.python:jython-standalone</include>

The jython pattern is not even tested against the jython dependency because
it returns from the function early instead of continuing the loop.* This is
code, the return statement should be continue statement instead for this to
work as I think was intended*:

private boolean matchAgainst( final String value, final List<String>
patterns, final boolean regionMatch )
{
    final String[] tokens = value.split( ":" );
    for ( String pattern : patterns )
    {
        String[] patternTokens = pattern.split( ":" );

        if ( patternTokens.length == 5 && tokens.length < 5 )
        {
            // 4th element is the classifier
            if ( !"*".equals( patternTokens[3] ) )
            {
                // classifier required, cannot be a match
                return false;
            }

But this is not all. I tried running the 3.3.0 Assembly plugin with
maven-common-artifact-filters artifact version 3.2.0 which seems to have
been significantly rewritten. However, that rejects my 5 components pattern
entirely. The comment in the code says "*we only accept 5 tokens if the
classifier = '*'*", which seems to be a departure from what the previous
version tried to support.

// we only accept 5 tokens if the classifier = '*'
if ( tokens.length == 5 )
{
    if ( tokens[3] != ANY )
    {
        throw new IllegalArgumentException( "Invalid pattern: " + pattern );
    }
    tokens = new char[][] { tokens[0], tokens[1], tokens[2], tokens[4] };
}


Was it intentional that the rewrite of the artifact filters stopped
supporting previously supported patterns?

Can we release Common Artifact Filters version 3.1.1 or such with the
return statement changed to continue statement and at the same time release
Assembly plugin 3.3.1 which would use this fixed Common Artifact Filters
version to unbreak this?


-- 
VH

Reply via email to