Skip to content

Problem with parsing Maven paths with tar.bz2 type/extension #96

Open

Description

@grgrzybek

with 4e0daa5 reverted, my test (in org.commonjava.atlas.maven.ident.util.ArtifactPathInfoTest) works:

@Test
public void matchNormalClassifier3()
{
    String path = "/io/syndesis/s2i/s2i/1.15.0.fuse-7_13_0-00001-redhat-00001/s2i-1.15.0.fuse-7_13_0-00001-redhat-00001-m2.tar.bz2";
    ArtifactPathInfo pathInfo = ArtifactPathInfo.parse( path );
    assertThat( pathInfo.getVersion(), equalTo( "1.15.0.fuse-7_13_0-00001-redhat-00001" ) );
    assertThat( pathInfo.getClassifier(), equalTo( "m2" ) );
    assertThat( pathInfo.getType(), equalTo( "tar.bz2" ) );
}

otherwise, the type is bz2 and the classifier is m2.tar

Activity

  1. grgrzybek commented on Aug 2, 2023

    @grgrzybek
    Author

    What's worse, is that normal artifacts like this won't work as well:

    @Test
    public void matchNormalClassifier3()
    {
        String path = "/commons-x/commons-x/1/commons-x-1-sources.jar.sha1";
        ArtifactPathInfo pathInfo = ArtifactPathInfo.parse( path );
        assertThat( pathInfo.getVersion(), equalTo( "1" ) );
        assertThat( pathInfo.getClassifier(), equalTo( "sources" ) );
        assertThat( pathInfo.getType(), equalTo( "jar.sha1" ) );
    }
    java.lang.AssertionError: 
    Expected: "sources"
         but: was "sources.jar"
    Expected :sources
    Actual   :sources.jar
    
  2. grgrzybek commented on Aug 2, 2023

    @grgrzybek
    Author

    I'd rather assume that classifier doesn't contain dots, but it may contain dashes - see https://repo1.maven.org/maven2/org/apache/activemq/activemq-karaf/5.18.2/ with classifiers like activemq-webconsole or features-core.

  3. cstamas commented on Aug 2, 2023

    @cstamas

    Yes, if classifier contains dots, you are doomed 😄

    But, you KNOW what is prefix (artifactId + version), strip that off, what remains is (possibly) classifier and extension. For example, this is what happens in indexer (does NOT work if classifier contains dot):
    https://github.com/apache/maven-indexer/blob/master/search-backend-remoterepository/src/main/java/org/apache/maven/search/backend/remoterepository/extractor/ResponseExtractorSupport.java

  4. grgrzybek commented on Aug 2, 2023

    @grgrzybek
    Author

    thanks for comment - Github is a small place ;)

    the problem is how to split classifier + . + multidotted-extension...

  5. cstamas commented on Aug 2, 2023

    @cstamas

    See the code i pasted (last method): first strip off known hashes, then strips off known prefix (artifactId + version) and then IF you assume classifier does not have dot (and maven would not allow it: ), everything "dotted" is extension. That code above works for cases like "tar.gz", "tar.bz2" etc.

    Debug this UT https://github.com/apache/maven-indexer/blob/master/search-backend-remoterepository/src/test/java/org/apache/maven/search/backend/remoterepository/internal/RemoteRepositorySearchBackendImplTest.java#L166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions