Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade lucence to 9.x with proper JPMS #8362

Merged
merged 27 commits into from
Apr 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
923ab5e
Upgrade lucence to 9.x with proper JPMS
Siedlerchr Dec 26, 2021
a4ab761
Pass IndexWriter on search, use try with resources
Siedlerchr Dec 26, 2021
52f8cc8
checkstyle
Siedlerchr Dec 27, 2021
814eb0d
Added lucene.codecs to build.gradle and module.info
calixtus Dec 27, 2021
5250ce4
test with providing info in merged module
Siedlerchr Dec 31, 2021
1afb09e
Merge remote-tracking branch 'upstream/main' into lucenceUpgrade
Siedlerchr Dec 31, 2021
b2f6d8d
add uses
Siedlerchr Jan 1, 2022
2f7ffad
Merge remote-tracking branch 'upstream/main' into lucenceUpgrade
Siedlerchr Jan 4, 2022
849da3d
further testing
Siedlerchr Jan 4, 2022
e5e0f3d
try debug mode
Siedlerchr Jan 7, 2022
259945f
add analysis and highlighter to module info
Siedlerchr Jan 7, 2022
1ef7d2a
fix some potential resource leaks
Siedlerchr Jan 8, 2022
6f1a82c
Step lucene index version
btut Jan 8, 2022
618dc4a
reenable normale options
Siedlerchr Jan 8, 2022
80ad646
try init directly
Siedlerchr Jan 8, 2022
33a826b
try excluding useless codecs
Siedlerchr Jan 8, 2022
81f08ef
Merge remote-tracking branch 'upstream/main' into lucenceUpgrade
Siedlerchr Mar 30, 2022
8c16129
update to lucence 9.1
Siedlerchr Mar 30, 2022
4fd89c7
try wit explicit dependency
Siedlerchr Mar 30, 2022
8720970
state use
Siedlerchr Mar 30, 2022
915b5bf
remove from merged
Siedlerchr Mar 30, 2022
9b76fe1
reenable options
Siedlerchr Apr 1, 2022
3188baf
cleanup some modules
Siedlerchr Apr 1, 2022
8dd352f
checkstyle
Siedlerchr Apr 1, 2022
4dcb7f8
Merge remote-tracking branch 'upstream/main' into lucenceUpgrade
Siedlerchr Apr 5, 2022
3c8c5c4
use old index path
Siedlerchr Apr 5, 2022
2bf3050
Add changelog
Siedlerchr Apr 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 7 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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',
Expand All @@ -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"
Expand Down
Binary file removed lib/lucene.jar
Binary file not shown.
23 changes: 0 additions & 23 deletions lucene-jar/lib/build.gradle

This file was deleted.

11 changes: 0 additions & 11 deletions lucene-jar/settings.gradle

This file was deleted.

17 changes: 12 additions & 5 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -65,7 +63,6 @@
requires org.libreoffice.uno;

// Other modules
requires commons.logging;
requires com.google.common;
requires jakarta.inject;
requires reactfx;
Expand Down Expand Up @@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down