Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
grgrzybek opened this issue Aug 2, 2023 · 5 comments
Open

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

grgrzybek opened this issue Aug 2, 2023 · 5 comments

Comments

@grgrzybek
Copy link

grgrzybek commented Aug 2, 2023

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

@grgrzybek
Copy link
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

@grgrzybek
Copy link
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.

@cstamas
Copy link

cstamas commented Aug 2, 2023

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

@grgrzybek
Copy link
Author

thanks for comment - Github is a small place ;)

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

@cstamas
Copy link

cstamas commented Aug 2, 2023

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants