diff --git a/core/src/main/java/org/jclouds/JcloudsVersion.java b/core/src/main/java/org/jclouds/JcloudsVersion.java index 731eb089a6..f23118e55b 100644 --- a/core/src/main/java/org/jclouds/JcloudsVersion.java +++ b/core/src/main/java/org/jclouds/JcloudsVersion.java @@ -38,9 +38,13 @@ public class JcloudsVersion { static final String VERSION_RESOURCE_FILE = "META-INF/maven/org.apache.jclouds/jclouds-core/pom.properties"; private static final String VERSION_PROPERTY_NAME = "version"; - // x.y.z or x.y.z-alpha.n or x.y.z-beta.n or x.y.z-rc.n or x.y.z-SNAPSHOT - see http://semver.org + /* + * x.y.z or x.y.z-incubating or x.y.z-alpha.n or x.y.z-beta.n or x.y.z-rc.n or x.y.z-SNAPSHOT - + * see http://semver.org. Note that x.y.z-incubating does *not* meet the + * semver criteria for a *release* version. + */ private static final Pattern SEMANTIC_VERSION_PATTERN = - Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(?:-(alpha|beta|rc)\\.(\\d+)|-SNAPSHOT)?"); + Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)(?:-(alpha|beta|rc)\\.(\\d+)|-incubating|-SNAPSHOT)?"); private static final String ALPHA_VERSION_IDENTIFIER = "alpha"; private static final String BETA_VERSION_IDENTIFIER = "beta"; diff --git a/core/src/test/java/org/jclouds/JcloudsVersionTest.java b/core/src/test/java/org/jclouds/JcloudsVersionTest.java index f6b095e98e..320a19d33c 100644 --- a/core/src/test/java/org/jclouds/JcloudsVersionTest.java +++ b/core/src/test/java/org/jclouds/JcloudsVersionTest.java @@ -68,6 +68,16 @@ public class JcloudsVersionTest { new JcloudsVersion("1.2.3-rc.4-SNAPSHOT"); } + @Test(expectedExceptions = { IllegalArgumentException.class }) + public void testFailsIfIncubatingSnapshot() { + new JcloudsVersion("1.2.3-incubating-SNAPSHOT"); + } + + @Test(expectedExceptions = { IllegalArgumentException.class }) + public void testFailsIfNumberedIncubating() { + new JcloudsVersion("1.2.3-incubating.1"); + } + @Test public void testExtractsVersionFromResourceFile() { JcloudsVersion version = new JcloudsVersion(); @@ -99,9 +109,21 @@ public class JcloudsVersionTest { JcloudsVersion version = new JcloudsVersion("1.2.3"); assertFalse(version.alpha, "Expected non-alpha"); assertFalse(version.beta, "Expected non-beta"); + assertFalse(version.releaseCandidate, "Expected non-release candidate"); assertNull(version.alphaVersion); assertNull(version.betaVersion); + assertNull(version.releaseCandidateVersion); + } + + @Test + public void testSupportsIncubatingReleaseVersion() { + // *not* a semver-compliant release version! + JcloudsVersion version = new JcloudsVersion("1.2.3-incubating"); + assertFalse(version.alpha, "Expected non-alpha"); + assertFalse(version.beta, "Expected non-beta"); assertFalse(version.releaseCandidate, "Expected non-release candidate"); + assertNull(version.alphaVersion); + assertNull(version.betaVersion); assertNull(version.releaseCandidateVersion); }