diff --git a/lucene/core/src/java/org/apache/lucene/util/Constants.java b/lucene/core/src/java/org/apache/lucene/util/Constants.java index 353a5be12ae..4ac00bd753c 100644 --- a/lucene/core/src/java/org/apache/lucene/util/Constants.java +++ b/lucene/core/src/java/org/apache/lucene/util/Constants.java @@ -117,9 +117,14 @@ public final class Constants { Package pkg = LucenePackage.get(); String v = (pkg == null) ? null : pkg.getImplementationVersion(); if (v == null) { - v = LUCENE_MAIN_VERSION + "-SNAPSHOT"; - } else if (!v.startsWith(LUCENE_MAIN_VERSION)) { - v = LUCENE_MAIN_VERSION + "-SNAPSHOT " + v; + String parts[] = LUCENE_MAIN_VERSION.split("\\."); + if (parts.length == 4) { + // alpha/beta + assert parts[2].equals("0"); + v = parts[0] + "." + parts[1] + "-SNAPSHOT"; + } else { + v = LUCENE_MAIN_VERSION + "-SNAPSHOT"; + } } LUCENE_VERSION = ident(v); } diff --git a/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java b/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java index 1c2433c56b2..c450fbc6998 100644 --- a/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java +++ b/lucene/core/src/test/org/apache/lucene/index/TestCheckIndex.java @@ -119,9 +119,19 @@ public class TestCheckIndex extends LuceneTestCase { // common-build.xml sets lucene.version final String version = System.getProperty("lucene.version"); assertNotNull( "null version", version); + final String constantVersion; + String parts[] = Constants.LUCENE_MAIN_VERSION.split("\\."); + if (parts.length == 4) { + // alpha/beta version: pull the real portion + assert parts[2].equals("0"); + constantVersion = parts[0] + "." + parts[1]; + } else { + // normal version + constantVersion = Constants.LUCENE_MAIN_VERSION; + } assertTrue("Invalid version: "+version, - version.equals(Constants.LUCENE_MAIN_VERSION+"-SNAPSHOT") || - version.equals(Constants.LUCENE_MAIN_VERSION)); + version.equals(constantVersion+"-SNAPSHOT") || + version.equals(constantVersion)); assertTrue(Constants.LUCENE_VERSION + " should start with: "+version, Constants.LUCENE_VERSION.startsWith(version)); }