I work on a large set of Maven-built services with a parent pom that uses a BOM using version ranges. In general, this works perfectly fine, when the available version is NOT a snapshot.
I'm now working on some new code that uses the same mechanism, but the only available version is a SNAPSHOT version. When I run the Maven build, it says "no versions available".
My version range is "[2.9.0, 2.9.100]". The available version is 2.9.0-SNAPSHOT, and that fails.
In a related version, using a version range of "[2.7.0, 2.7.100)", when the available version is 2.7.0 or 2.7.1, this works fine.
From what I've read, I believe it implies that "2.9.0-SNAPSHOT" is "more than" 2.9.0, so this should work. Just in case, I tried an experiment of changing the range to "[2.8.9, 2.9.100)", but it still says there is no version available.
I'm aware of the advice that "version ranges are not recommended". In general, this works for us. Do snapshots not work with version ranges?
I'm presently using Maven v3.8.2.
Update:
Note that if I change the version range to "[2.9.0-SNAPSHOT, 2.9.100-SNAPSHOT)", it does accept the "2.9.0-SNAPSHOT" version. I'm not sure if that helps in the long run.
CodePudding user response:
Here's what you can do: java -jar maven-artifact.jar n1 n2 n3 ... nx The maven-artifact jar that's part of every Maven distribution is also an executable jar, where you can add version numbers. E.g.
D:\>"%JAVA_HOME%"\bin\java -jar d:\apache-maven-3.8.1\lib\maven-artifact-3.8.1.jar 2.9.0 2.9.0-SNAPSHOT
Display parameters as parsed by Maven (in canonical form) and comparison result:
1. 2.9.0 == 2.9
2.9.0 > 2.9.0-SNAPSHOT
2. 2.9.0-SNAPSHOT == 2.9-snapshot
The rational: 2.9.0-SNAPSHOT will result in 2.9.0, hence the SNAPSHOT is before/smaller and will not be included if you o [2.9.0 . Here's the related javadoc: https://maven.apache.org/resolver/apidocs/org/eclipse/aether/util/version/GenericVersionScheme.html