Uploaded image for project: 'Maven Assembly Plugin'
  1. Maven Assembly Plugin
  2. MASSEMBLY-955

dependencySet includes filter with classifier breaks include of artifacts without classifier

    XMLWordPrintableJSON

Details

    Description

      I have created a demonstration repo for this issue at https://github.com/wilx/maven-assembly-includes-test-case. As demonstrated by the test projects in the repository, the filtering breaks with version 3.0.0 of Maven Assembly plugin but at least it finishes building something. If I try to update maven-common-artifact-filters to 3.2.0, it breaks the build completely because it does not like 5 components include pattern.

      Following is cut&paste of my email to dev mailing list:

      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?

      Can we fix the Common Artifact Filters version 3.2.0 to accept the inclusion filter with the classifier as do the previous versions?

       

      Attachments

        Issue Links

          Activity

            People

              cstamas Tamas Cservenak
              wilx Václav Haisman
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: