diff --git a/CHANGELOG.md b/CHANGELOG.md index 26e4a24f8f6..72d0130cc0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Changed +- We upgraded to Lucene 9.1 for the fulltext search. Thus, the now created search index cannot be read from older versions of JabRef anylonger and would need to be recreated if you switch back to an older version [#8362](https://github.com/JabRef/jabref/pull/8362) - We changed the list of CSL styles to those that support formatting bibliographies [#8421](https://github.com/JabRef/jabref/issues/8421) [citeproc-java#116](https://github.com/michel-kraemer/citeproc-java/issues/116) - The CSL preview styles now also support displaying data from cross references entries that are linked via the `crossref` field [#7378](https://github.com/JabRef/jabref/issues/7378) - We made the Search button in Web Search wider. We also skewed the panel titles to the left [#8397](https://github.com/JabRef/jabref/issues/8397) diff --git a/build.gradle b/build.gradle index 28d703edc27..46bfefbebbf 100644 --- a/build.gradle +++ b/build.gradle @@ -114,6 +114,12 @@ dependencies { implementation 'org.apache.pdfbox:fontbox:3.0.0-RC1' implementation 'org.apache.pdfbox:xmpbox:3.0.0-RC1' + implementation 'org.apache.lucene:lucene-core:9.1.0' + implementation 'org.apache.lucene:lucene-queryparser:9.1.0' + implementation 'org.apache.lucene:lucene-queries:9.1.0' + implementation 'org.apache.lucene:lucene-analysis-common:9.1.0' + implementation 'org.apache.lucene:lucene-highlighter:9.1.0' + implementation group: 'org.apache.commons', name: 'commons-csv', version: '1.9.0' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' implementation 'com.h2database:h2-mvstore:2.1.210' @@ -557,7 +563,6 @@ jlink { requires 'com.google.gson' requires 'org.slf4j' requires 'jakarta.xml.bind' - uses 'org.controlsfx.glyphfont.GlyphFont' uses 'com.airhacks.afterburner.views.ResourceLocator' uses 'com.airhacks.afterburner.injection.PresenterFactory' uses 'org.mariadb.jdbc.credential.CredentialPlugin' @@ -566,11 +571,7 @@ jlink { uses 'org.mariadb.jdbc.LocalInfileInterceptor' uses 'org.eclipse.jgit.transport.SshSessionFactory' uses 'org.eclipse.jgit.lib.GpgSigner' - provides 'org.apache.lucene.codecs.DocValuesFormat' with 'org.apache.lucene.codecs.lucene80.Lucene80DocValuesFormat' - provides 'org.controlsfx.glyphfont.GlyphFont' with 'org.controlsfx.glyphfont.FontAwesome' provides 'org.mariadb.jdbc.tls.TlsSocketPlugin' with 'org.mariadb.jdbc.internal.protocol.tls.DefaultTlsSocketPlugin' - provides 'com.microsoft.applicationinsights.core.dependencies.io.grpc.ServerProvider' with 'com.microsoft.applicationinsights.core.dependencies.io.grpc.netty.shaded.io.grpc.netty.NettyServerProvider' - provides 'com.microsoft.applicationinsights.core.dependencies.io.grpc.NameResolverProvider' with 'com.microsoft.applicationinsights.core.dependencies.io.grpc.internal.DnsNameResolverProvider' provides 'java.sql.Driver' with 'org.postgresql.Driver' provides 'org.mariadb.jdbc.authentication.AuthenticationPlugin' with 'org.mariadb.jdbc.internal.com.send.authentication.CachingSha2PasswordPlugin', 'org.mariadb.jdbc.internal.com.send.authentication.ClearPasswordPlugin', @@ -584,9 +585,7 @@ jlink { 'org.mariadb.jdbc.credential.env.EnvCredentialPlugin', 'org.mariadb.jdbc.credential.system.PropertiesCredentialPlugin' provides 'java.security.Provider' with 'org.bouncycastle.jce.provider.BouncyCastleProvider', - 'org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider' - provides 'com.microsoft.applicationinsights.core.dependencies.io.grpc.ManagedChannelProvider' with 'com.microsoft.applicationinsights.core.dependencies.io.grpc.netty.shaded.io.grpc.netty.NettyChannelProvider' - } + 'org.bouncycastle.pqc.jcajce.provider.BouncyCastlePQCProvider' } jpackage { outputDir = "distribution" diff --git a/lib/lucene.jar b/lib/lucene.jar deleted file mode 100644 index 758012cdc90..00000000000 Binary files a/lib/lucene.jar and /dev/null differ diff --git a/lucene-jar/lib/build.gradle b/lucene-jar/lib/build.gradle deleted file mode 100644 index b267c5c7e45..00000000000 --- a/lucene-jar/lib/build.gradle +++ /dev/null @@ -1,23 +0,0 @@ -plugins { - id 'java-library' - id 'com.github.johnrengelman.shadow' version '7.0.0' -} - -repositories { - mavenCentral() -} - -shadowJar { - mergeServiceFiles() -} - -dependencies { - implementation 'org.apache.lucene:lucene-core:8.9.0' - implementation ('org.apache.lucene:lucene-queryparser:8.9.0') { - exclude module: "lucene-sandbox" - } - implementation 'org.apache.lucene:lucene-queries:8.9.0' - implementation 'org.apache.lucene:lucene-analyzers-common:8.9.0' - implementation 'org.apache.lucene:lucene-backward-codecs:8.9.0' - implementation 'org.apache.lucene:lucene-highlighter:8.9.0' -} diff --git a/lucene-jar/settings.gradle b/lucene-jar/settings.gradle deleted file mode 100644 index d810394f855..00000000000 --- a/lucene-jar/settings.gradle +++ /dev/null @@ -1,11 +0,0 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * The settings file is used to specify which projects to include in your build. - * - * Detailed information about configuring a multi-project build in Gradle can be found - * in the user manual at https://docs.gradle.org/7.0.2/userguide/multi_project_builds.html - */ - -rootProject.name = 'lucene-jar' -include('lib') diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index d80ed36425f..afa28d89b41 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -46,8 +46,6 @@ with org.jabref.gui.logging.GuiWriter, org.jabref.gui.logging.ApplicationInsightsWriter; - requires applicationinsights.logging.log4j2; - // Preferences and XML requires java.prefs; requires jakarta.xml.bind; @@ -65,7 +63,6 @@ requires org.libreoffice.uno; // Other modules - requires commons.logging; requires com.google.common; requires jakarta.inject; requires reactfx; @@ -101,10 +98,20 @@ requires flexmark.util.ast; requires flexmark.util.data; requires com.h2database.mvstore; - requires lucene; - requires org.eclipse.jgit; + + // fulltext search + requires org.apache.lucene.core; + uses org.apache.lucene.codecs.lucene91.Lucene91Codec; + + requires org.apache.lucene.queryparser; + uses org.apache.lucene.queryparser.classic.MultiFieldQueryParser; + requires org.apache.lucene.analysis.common; + requires org.apache.lucene.highlighter; + + requires com.fasterxml.jackson.databind; requires com.fasterxml.jackson.dataformat.yaml; requires com.fasterxml.jackson.datatype.jsr310; requires net.harawata.appdirs; + } diff --git a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java index 181fd36b0ff..0a6f670c60e 100644 --- a/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java +++ b/src/main/java/org/jabref/gui/documentviewer/DocumentViewerViewModel.java @@ -19,6 +19,7 @@ import org.jabref.gui.AbstractViewModel; import org.jabref.gui.StateManager; +import org.jabref.logic.util.io.FileUtil; import org.jabref.model.entry.BibEntry; import org.jabref.model.entry.LinkedFile; import org.jabref.preferences.PreferencesService; @@ -105,10 +106,13 @@ private void setCurrentEntry(BibEntry entry) { } private void setCurrentDocument(Path path) { - try (PDDocument document = Loader.loadPDF(path.toFile())) { - currentDocument.set(new PdfDocumentViewModel(document)); + try { + if (FileUtil.isPDFFile(path)) { + PDDocument document = Loader.loadPDF(path.toFile()); + currentDocument.set(new PdfDocumentViewModel(document)); + } } catch (IOException e) { - LOGGER.error("Could not set Document Viewer", e); + LOGGER.error("Could not set Document Viewer for path {}", path, e); } } diff --git a/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java b/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java index 2fd7e54e5b0..f2c2a73bae8 100644 --- a/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java +++ b/src/main/java/org/jabref/logic/pdf/search/retrieval/PdfSearcher.java @@ -12,6 +12,7 @@ import org.jabref.model.pdf.search.SearchResult; import org.jabref.model.strings.StringUtil; +import org.apache.lucene.codecs.Codec; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.queryparser.classic.MultiFieldQueryParser; @@ -35,6 +36,8 @@ public final class PdfSearcher { private PdfSearcher(Directory indexDirectory) { this.indexDirectory = indexDirectory; + Codec.forName("Lucene91"); + } public static PdfSearcher of(BibDatabaseContext databaseContext) throws IOException { @@ -72,6 +75,7 @@ public PdfSearchResults search(final String searchString, final int maxHits) resultDocs.add(new SearchResult(searcher, query, scoreDoc)); } return new PdfSearchResults(resultDocs); + } catch (ParseException e) { LOGGER.warn("Could not parse query: '{}'!\n{}", searchString, e.getMessage()); return new PdfSearchResults();