Reputation: 1989
I'm developing a server that hosts a maven repo and face the problem that Maven incorrectly resolves SNAPSHOT-versions if the snapshot is not in a specific format. After looking up the rules for versions, I understand that the qualifier can be any string, so I expect maven to be able to download dependencies with any qualifier. This doesn't match my experience however.
The repo has the following folder structure (assuming a maven project a.b.c:a.b.c.d:1.0.0-SNAPSHOT
):
<repo-root>
|-a
|-b
|-c
|-a.b.c.d
|-maven-metadata.xml
|-1.0.0-SNAPSHOT
|-a.b.c.d-1.0.0-20190213.120000-1.jar
|-maven-metadata.xml
If I try to resolve a.b.c.d-SNAPSHOT, this works just fine. I can see in the maven log that it looks for a/b/c/a.b.c.d/1.0.0-SNAPSHOT/maven-metadata.xml
and then downloads the correct JAR-file. So far so good.
But if I change the qualifier to something else (like removing the -1 at the end), maven is unable to resolve the file! Instead of looking for
<repo-root>/a/b/c/a.b.c.d/1.0.0-SNAPSHOT/<jar-file>
(which would be correct), it looks at
<repo-root>/a/b/c/a.b.c.d/1.0.0-20190213.120000/<jar-file>
which is obviously wrong. This happens with every qualifier that doesn't fit the format
\d\.\d\.\d-\d{8}.\d{6}-\d+
Why can't Maven resolve such qualifiers? Is the format specified somewhere or is this just a maven bug?
Upvotes: 2
Views: 223
Reputation: 35903
In general, Maven versions can be any String (like 1.2.3-RELEASE
, 1-1456
or dontknow
). Versions ending in -SNAPSHOT
have the special meaning that they are resolved against the latest build version.
The different versions for one specific SNAPSHOT (like 1.0-SNAPSHOT
) are distinguished by the timestamps you mentioned in your question. I do not know whether this format is really a "Maven standard", but I guess so because it is the same in all common repository managers and you experienced problems in not using it. I would strongly advise against using different kinds of timestamps even if you make it work because the expectation of every Maven plugin is that timestamped SNAPSHOT versions have a defined and given format (whether this is "official" or not).
By the way: I would be very interested to hear why you develop your own Maven repository.
Upvotes: 2