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

feat: support version which contains underscore #11

Merged
merged 5 commits into from
Jan 31, 2025

Conversation

gshanbhag525
Copy link
Contributor

eg.

=1087.v16065d268466, <1087.1089.v2f1b_9a_b_040e4

for org.jenkins-ci.plugins:credentials maven package

@knqyf263 please review.

eg.
>=1087.v16065d268466, <1087.1089.v2f1b_9a_b_040e4

for org.jenkins-ci.plugins:credentials
@masahiro331
Copy link
Owner

#10

Add test

@masahiro331
Copy link
Owner

@gshanbhag525
Copy link
Contributor Author

used act https://github.com/nektos/act to verfiy workflow locally.

@knqyf263
Copy link
Collaborator

When version strings do not follow semantic versioning, a more complex set of rules is required. The Maven coordinate is split in tokens between dots ('.'), hyphens ('-'), underscore ('_') and transitions between digits and characters. The separator is recorded and will have effect on the order. A transition between digits and characters is equivalent to a hyphen. Empty tokens are replaced with "0". This gives a sequence of version numbers (numeric tokens) and version qualifiers (non-numeric tokens) with "." or "-" prefixes. Versions are expected to start with numbers.

https://maven.apache.org/pom.html#Dependency_Version_Requirement_Specification

@knqyf263
Copy link
Collaborator

Hmm, but it looks like Maven doesn't use underscore for separators, while dots and hyphens are treated as separators.

@knqyf263
Copy link
Collaborator

The unit tests also don't contain the cases using _.

@knqyf263
Copy link
Collaborator

I tested Maven.

$ mvn dependency:get -DgroupId=org.apache.maven -DartifactId=maven-artifact -Dversion=3.9.6
$ java -jar ~/.m2/repository/org/apache/maven/maven-artifact/3.9.6/maven-artifact-3.9.6.jar "1.0.ALPHA" "1.0-ALPHA"
Display parameters as parsed by Maven (in canonical form and as a list of tokens) and comparison result:
1. 1.0.ALPHA -> 1-alpha; tokens: [1, [alpha]]
   1.0.ALPHA == 1.0-ALPHA
2. 1.0-ALPHA -> 1-alpha; tokens: [1, [alpha]]
bash-4.2# java -jar ~/.m2/repository/org/apache/maven/maven-artifact/3.9.6/maven-artifact-3.9.6.jar "1.0_ALPHA" "1.0-ALPHA"
Display parameters as parsed by Maven (in canonical form and as a list of tokens) and comparison result:
1. 1.0_ALPHA -> 1-_alpha; tokens: [1, [_alpha]]
   1.0_ALPHA > 1.0-ALPHA
2. 1.0-ALPHA -> 1-alpha; tokens: [1, [alpha]]

In conclusion, the document is wrong. _ is interpreted as a character.

@knqyf263 knqyf263 merged commit f4974fa into masahiro331:master Jan 31, 2025
1 check passed
@gshanbhag525 gshanbhag525 deleted the gun-fix-maven-version branch February 4, 2025 08:58
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

Successfully merging this pull request may close these issues.

3 participants