Closed diabolicallabs closed 4 years ago
Yes, the test for it looks wrong.
Do you have examples that we can add as tests?
I think maybe the extension goes after the version based on the following mvn command.
// mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=groupId:artifactId:version[:packaging[:classifier]]
let coordinates = mavenParser('junit:junit:4.12:jar:sources')
console.log(coordinates)
// {
// groupId: 'junit',
// artifactId: 'junit',
// version: '4.12',
// extension: 'jar',
// classifier: 'sources'
// }
It looks like there is no standard way to parse Maven coordinate strings. I do not know where I got the format from in the first place, but the current format is also used in the community:
Eclipse Aether Parser, Bazel rules_jvm_external, Apache Buildr, and maven-jaxb2-plugin are using the current syntax
As there is no standard way coordinate strings should be parsed, I'm not sure what to do. We could make a breaking change of the parser, and declare that the format used by "maven-dependency-plugin" is correct.
Or, we could document the current behaviour and define that as our pattern.
Or, implement both and let the consumers decide which pattern to use..
I believe the current format is OK, since it is used by other tools in the community. And because the package is ~20 lines of code it is easy to implement others locally.
The other mvn-* packages can still be used with a custom parser.
Okay. Thanks for looking at it.
When passing an extension and classifier to mvn-artifact-name-parser.parseFileName it doesn't format the artifact properly. The version ends up with the classifier. The following code seems to fix the problem.