LUCENE-10260: Luke's about window no longer shows version number (#473)

This commit is contained in:
Dawid Weiss 2021-11-26 08:32:23 +01:00 committed by GitHub
parent a590c6d2a0
commit 651755aab7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 34 deletions

View File

@ -239,6 +239,9 @@ API Changes
unwrap wrappers/delegators that are added by Lucene's testing framework. This will allow
testing new MMapDirectory implementation based on JDK Project Panama. (Uwe Schindler)
* LUCENE-10260: LucenePackage class has been removed. The implementation string can be
retrieved from Version.getPackageImplementationVersion(). (Uwe Schindler, Dawid Weiss)
Improvements
---------------------

View File

@ -24,6 +24,11 @@ means that interval function prefixes ("fn:") and the '@' character after parent
parse differently than before. If you need the exact previous behavior, clone the StandardSyntaxParser from the previous version of Lucene and create a custom query parser
with that parser.
## LucenePackage class removed (LUCENE-10260)
LucenePackage class has been removed. The implementation string can be
retrieved from Version.getPackageImplementationVersion().
## Directory API is now little endian (LUCENE-9047)
DataOutput's writeShort, writeInt, and writeLong methods now encode with

View File

@ -1,28 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.lucene;
/** Lucene's package information, including version. */
public final class LucenePackage {
private LucenePackage() {} // can't construct
/** Return Lucene's package, including version information. */
public static Package get() {
return LucenePackage.class.getPackage();
}
}

View File

@ -16,8 +16,11 @@
*/
package org.apache.lucene.util;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.text.ParseException;
import java.util.Locale;
import java.util.jar.Manifest;
/**
* Use by certain classes to match version compatibility across releases of Lucene.
@ -67,6 +70,9 @@ public final class Version {
*/
public static final int MIN_SUPPORTED_MAJOR = Version.LATEST.major - 1;
/** @see #getPackageImplementationVersion() */
private static String implementationVersion;
/**
* Parse a version number of the form {@code "major.minor.bugfix.prerelease"}.
*
@ -302,4 +308,46 @@ public final class Version {
public int hashCode() {
return encodedValue;
}
/**
* Return Lucene's full implementation version. This version is saved in Lucene's metadata at
* build time (JAR manifest, module info). If it is not available, an {@code unknown}
* implementation version is returned.
*
* @return Lucene implementation version string, never {@code null}.
*/
public static String getPackageImplementationVersion() {
// Initialize the lazy value.
synchronized (Version.class) {
if (implementationVersion == null) {
String version;
Package p = Version.class.getPackage();
version = p.getImplementationVersion();
if (version == null) {
var module = Version.class.getModule();
if (module.isNamed()) {
// Running as a module? Try parsing the manifest manually.
try (var is = module.getResourceAsStream("/META-INF/MANIFEST.MF")) {
if (is != null) {
Manifest m = new Manifest(is);
version = m.getMainAttributes().getValue("Implementation-Version");
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
if (version == null) {
version = "unknown";
}
implementationVersion = version;
}
return implementationVersion;
}
}
}

View File

@ -29,7 +29,6 @@ import java.awt.Insets;
import java.awt.Window;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Objects;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
@ -42,7 +41,6 @@ import javax.swing.ScrollPaneConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import org.apache.lucene.LucenePackage;
import org.apache.lucene.luke.app.desktop.Preferences;
import org.apache.lucene.luke.app.desktop.PreferencesFactory;
import org.apache.lucene.luke.app.desktop.util.DialogOpener;
@ -51,6 +49,7 @@ import org.apache.lucene.luke.app.desktop.util.ImageUtils;
import org.apache.lucene.luke.app.desktop.util.MessageUtils;
import org.apache.lucene.luke.app.desktop.util.URLLabel;
import org.apache.lucene.luke.models.LukeException;
import org.apache.lucene.util.Version;
/** Factory of about dialog */
public final class AboutDialogFactory implements DialogOpener.DialogFactory {
@ -173,15 +172,15 @@ public final class AboutDialogFactory implements DialogOpener.DialogFactory {
}
private static final String LUCENE_IMPLEMENTATION_VERSION =
LucenePackage.get().getImplementationVersion();
Version.getPackageImplementationVersion();
private static final String LICENSE_NOTICE =
"<p>[Implementation Version]</p>"
"<p>[Lucene Implementation Version]</p>"
+ "<p>"
+ (Objects.nonNull(LUCENE_IMPLEMENTATION_VERSION) ? LUCENE_IMPLEMENTATION_VERSION : "")
+ LUCENE_IMPLEMENTATION_VERSION
+ "</p>"
+ "<p>[License]</p>"
+ "<p>Luke is distributed under <a href=\"http://www.apache.org/licenses/LICENSE-2.0\">Apache License Version 2.0</a> (http://www.apache.org/licenses/LICENSE-2.0) "
+ "<p>Luke is distributed under <a href=\"https://www.apache.org/licenses/LICENSE-2.0\">Apache License Version 2.0</a> (https://www.apache.org/licenses/LICENSE-2.0) "
+ "and includes <a href=\"https://www.elegantthemes.com/blog/resources/elegant-icon-font\">The Elegant Icon Font</a> (https://www.elegantthemes.com/blog/resources/elegant-icon-font) "
+ "licensed under <a href=\"https://opensource.org/licenses/MIT\">MIT</a> (https://opensource.org/licenses/MIT)</p>"
+ "<p>[Brief history]</p>"