You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Václav Haisman <vh...@gmail.com> on 2021/11/16 13:51:13 UTC

Maven Assembly / Common Artifact Filters issues and defect

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

Re: Maven Assembly / Common Artifact Filters issues and defect

Posted by Václav Haisman <vh...@gmail.com>.
On 02. 12. 21 19:09, Michael Osipov wrote:
> Am 2021-12-01 um 21:06 schrieb Václav Haisman:
>> On 16. 11. 21 20:58, Václav Haisman wrote:
>>> On 16. 11. 21 17:36, Slawomir Jaranowski wrote:
>>>> Hi,
>>>> Thanks for reporting.
>>>>
>>>> Does your issue is similar to [1] - If yes please comment, vote
>>>> or if it is something else you can create a new issue.
>>>
>>> I have created a new issue. In my case, Assembly plugin 2.5.5 works and
>>> 3.0.0+ breaks. New issue:
>>> https://issues.apache.org/jira/browse/MASSEMBLY-955
>>>
>>>>
>>>> [1] https://issues.apache.org/jira/browse/MASSEMBLY-607
> 
> Ahoj Václav,
> 
> been too busy with other stuff. Please ping me on GH by mid of next
> week. Won't have the time to get a closer look earlier. If anyone beat
> me, that's fine.
> 

Ping.

https://issues.apache.org/jira/browse/MASSEMBLY-955
https://github.com/apache/maven-common-artifact-filters/pull/24
https://github.com/apache/maven-assembly-plugin/pull/48


-- 
VH

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Maven Assembly / Common Artifact Filters issues and defect

Posted by Michael Osipov <mi...@apache.org>.
Am 2021-12-01 um 21:06 schrieb Václav Haisman:
> On 16. 11. 21 20:58, Václav Haisman wrote:
>> On 16. 11. 21 17:36, Slawomir Jaranowski wrote:
>>> Hi,
>>> Thanks for reporting.
>>>
>>> Does your issue is similar to [1] - If yes please comment, vote
>>> or if it is something else you can create a new issue.
>>
>> I have created a new issue. In my case, Assembly plugin 2.5.5 works and
>> 3.0.0+ breaks. New issue:
>> https://issues.apache.org/jira/browse/MASSEMBLY-955
>>
>>>
>>> [1] https://issues.apache.org/jira/browse/MASSEMBLY-607

Ahoj Václav,

been too busy with other stuff. Please ping me on GH by mid of next 
week. Won't have the time to get a closer look earlier. If anyone beat 
me, that's fine.

M

Re: Maven Assembly / Common Artifact Filters issues and defect

Posted by Václav Haisman <vh...@gmail.com>.
On 16. 11. 21 20:58, Václav Haisman wrote:
> On 16. 11. 21 17:36, Slawomir Jaranowski wrote:
>> Hi,
>> Thanks for reporting.
>>
>> Does your issue is similar to [1] - If yes please comment, vote
>> or if it is something else you can create a new issue.
> 
> I have created a new issue. In my case, Assembly plugin 2.5.5 works and
> 3.0.0+ breaks. New issue:
> https://issues.apache.org/jira/browse/MASSEMBLY-955
> 
>>
>> [1] https://issues.apache.org/jira/browse/MASSEMBLY-607

PING.
-- 
VH

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Maven Assembly / Common Artifact Filters issues and defect

Posted by Václav Haisman <vh...@gmail.com>.
On 16. 11. 21 17:36, Slawomir Jaranowski wrote:
> Hi,
> Thanks for reporting.
> 
> Does your issue is similar to [1] - If yes please comment, vote
> or if it is something else you can create a new issue.

I have created a new issue. In my case, Assembly plugin 2.5.5 works and
3.0.0+ breaks. New issue:
https://issues.apache.org/jira/browse/MASSEMBLY-955

> 
> [1] https://issues.apache.org/jira/browse/MASSEMBLY-607
> 
> 
> wt., 16 lis 2021 o 14:51 Václav Haisman <vh...@gmail.com> napisał(a):
> 
>> 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
>>
> 
> 


-- 
VH

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Maven Assembly / Common Artifact Filters issues and defect

Posted by Slawomir Jaranowski <s....@gmail.com>.
Hi,
Thanks for reporting.

Does your issue is similar to [1] - If yes please comment, vote
or if it is something else you can create a new issue.

[1] https://issues.apache.org/jira/browse/MASSEMBLY-607


wt., 16 lis 2021 o 14:51 Václav Haisman <vh...@gmail.com> napisał(a):

> 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
>


-- 
Sławomir Jaranowski