LUCENE-1666: if JAR has null impl version, fallback to Lucene's main version; also add main version in, if the JAR's impl version doesn't contain it

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@779625 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2009-05-28 15:38:44 +00:00
parent 3c3b283e3c
commit 6dcd9628f5
2 changed files with 11 additions and 4 deletions

View File

@ -56,10 +56,10 @@ public final class Constants {
public static final String LUCENE_VERSION;
public static final String LUCENE_MAIN_VERSION = "2.9-dev";
public static final String LUCENE_MAIN_VERSION = "2.9";
static {
String v = LUCENE_MAIN_VERSION;
String v = LUCENE_MAIN_VERSION + "-dev";
try {
// TODO: this should have worked, but doesn't seem to?
// Package.getPackage("org.apache.lucene.util").getImplementationVersion();
@ -69,7 +69,14 @@ public final class Constants {
try {
Manifest manifest = new Manifest(s);
Attributes attr = manifest.getMainAttributes();
v = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
String value = attr.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
if (value != null) {
if (value.indexOf(LUCENE_MAIN_VERSION) == -1) {
v = value + " [" + LUCENE_MAIN_VERSION + "]";
} else {
v = value;
}
}
} finally {
if (s != null) {
s.close();

View File

@ -71,7 +71,7 @@ public class TestCheckIndex extends LuceneTestCase {
public void testLuceneConstantVersion() throws IOException {
// common-build.xml sets lucene.version
final String version = System.getProperty("lucene.version");
assertEquals(version, Constants.LUCENE_MAIN_VERSION);
assertEquals(version, Constants.LUCENE_MAIN_VERSION+"-dev");
assertTrue(Constants.LUCENE_VERSION.startsWith(version));
}
}