From 3e0284dd551cdd24c77cd420642adb8752e41750 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Thu, 27 Feb 2020 11:07:07 +0100 Subject: [PATCH] Add graal info to module file (#6010) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update citeproc-java to 2.1.0-SNAPSHOT and enable experimental pure-Java mode * Add graal info to module file * Update module-info.java * fix loading of CSL styles using correct path * use acm stlye as default * disbale debug mode * add changelog entry Co-authored-by: Michel Krämer Co-authored-by: Christoph --- CHANGELOG.md | 1 + build.gradle | 4 +-- src/main/java/module-info.java | 6 +++- .../logic/citationstyle/CSLAdapter.java | 4 ++- .../logic/citationstyle/CitationStyle.java | 30 ++++++------------- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1477782a160..49dc2aac9bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where changing entry type doesn't always work when biblatex source is shown. [#5905](https://github.com/JabRef/jabref/issues/5905) - We fixed an issue where the group and the link column were not updated after changing the entry in the main table. [#5985](https://github.com/JabRef/jabref/issues/5985) - We fixed an issue where reordering the groups was not possible after inserting an article. [#6008](https://github.com/JabRef/jabref/issues/6008) +- We fixed an issue where citation styles except the default "Preview" could not be used. [#56220](https://github.com/JabRef/jabref/issues/5622) ### Removed diff --git a/build.gradle b/build.gradle index 3daa53628ce..1b69c25572e 100644 --- a/build.gradle +++ b/build.gradle @@ -181,7 +181,7 @@ dependencies { implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '3.0.0-SNAPSHOT' annotationProcessor group: 'org.apache.logging.log4j', name: 'log4j-core', version: '3.0.0-SNAPSHOT' - implementation 'de.undercouch:citeproc-java:2.0.0' + implementation 'de.undercouch:citeproc-java:2.1.0-SNAPSHOT' implementation group: 'jakarta.activation', name: 'jakarta.activation-api', version: '1.2.1' implementation group: 'jakarta.xml.bind', name: 'jakarta.xml.bind-api', version: '2.3.2' @@ -546,7 +546,7 @@ task deleteInstallerTemp(type: Delete) { jpackage.dependsOn deleteInstallerTemp jlink { - options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages'] + options = ['--strip-debug','--compress', '2', '--no-header-files', '--no-man-pages'] launcher { name = 'JabRef' } diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index a90f0226983..6ef392d0005 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -61,7 +61,11 @@ requires jbibtex; requires citeproc.java; requires antlr.runtime; - requires org.graalvm.js; + requires org.graalvm.truffle; + requires org.graalvm.sdk; + requires transitive org.graalvm.js; + requires java.scripting; + requires jdk.internal.vm.compiler; requires org.apache.xmpbox; requires de.saxsys.mvvmfx.validation; requires com.google.gson; diff --git a/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java b/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java index 5728839efe9..6d34c21c514 100644 --- a/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java +++ b/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java @@ -14,6 +14,7 @@ import org.jabref.model.strings.LatexToUnicodeAdapter; import de.undercouch.citeproc.CSL; +import de.undercouch.citeproc.DefaultAbbreviationProvider; import de.undercouch.citeproc.ItemDataProvider; import de.undercouch.citeproc.bibtex.BibTeXConverter; import de.undercouch.citeproc.csl.CSLItemData; @@ -66,7 +67,8 @@ public synchronized List makeBibliography(List bibEntries, Str private void initialize(String newStyle, CitationStyleOutputFormat newFormat) throws IOException { if ((cslInstance == null) || !Objects.equals(newStyle, style)) { // lang and forceLang are set to the default values of other CSL constructors - cslInstance = new CSL(dataProvider, new JabRefLocaleProvider(), newStyle, "en-US", false); + cslInstance = new CSL(dataProvider, new JabRefLocaleProvider(), + new DefaultAbbreviationProvider(), null, newStyle, "en-US", false, true); style = newStyle; } diff --git a/src/main/java/org/jabref/logic/citationstyle/CitationStyle.java b/src/main/java/org/jabref/logic/citationstyle/CitationStyle.java index 05285948ccd..99ddd023239 100644 --- a/src/main/java/org/jabref/logic/citationstyle/CitationStyle.java +++ b/src/main/java/org/jabref/logic/citationstyle/CitationStyle.java @@ -6,9 +6,6 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.nio.file.FileSystem; -import java.nio.file.FileSystemAlreadyExistsException; -import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.nio.file.Path; @@ -25,6 +22,7 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; +import org.jabref.JabRefMain; import org.jabref.logic.util.StandardFileType; import de.undercouch.citeproc.helper.CSLUtils; @@ -138,28 +136,18 @@ public static List discoverCitationStyles() { return STYLES; } - URL url = CitationStyle.class.getResource(STYLES_ROOT); - if (url == null) { - return Collections.emptyList(); - } + URL url = JabRefMain.class.getResource(STYLES_ROOT + "/acm-siggraph.csl"); + Objects.requireNonNull(url); + try { URI uri = url.toURI(); - if ("jar".equals(uri.getScheme())) { - try (FileSystem fs = FileSystems.newFileSystem(uri, Collections.emptyMap())) { - Path path = fs.getPath(STYLES_ROOT); - STYLES.addAll(discoverCitationStylesInPath(path)); - } catch (FileSystemAlreadyExistsException e) { - try (FileSystem fs = FileSystems.getFileSystem(uri)) { - Path path = fs.getPath(STYLES_ROOT); - STYLES.addAll(discoverCitationStylesInPath(path)); - } - } - } else { - STYLES.addAll(discoverCitationStylesInPath(Paths.get(uri))); - } + Path path = Path.of(uri).getParent(); + + STYLES.addAll(discoverCitationStylesInPath(path)); + return STYLES; } catch (URISyntaxException | IOException e) { - LOGGER.error("something went wrong while searching available CitationStyles. Are you running directly from source code?", e); + LOGGER.error("something went wrong while searching available CitationStyles", e); return Collections.emptyList(); } }