Skip to content

Add doi-to-bibtex to examples and JabKit#14244

Merged
koppor merged 31 commits into
mainfrom
add-doi-to-bibtex-example
Nov 9, 2025
Merged

Add doi-to-bibtex to examples and JabKit#14244
koppor merged 31 commits into
mainfrom
add-doi-to-bibtex-example

Conversation

@koppor

@koppor koppor commented Nov 6, 2025

Copy link
Copy Markdown
Member

Strongly demanded by the community. Was available inside JabRef; now we can offer as CLI.

Kind of follow-up to #14233.

We use CrossRef

Steps to test

Create and modify debug configuration for org.jabref.JabKit#main

image

Mandatory checks

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • I described the change in CHANGELOG.md in a way that is understandable for the average user (if change is visible to the user)
  • [/] I checked the user documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request updating file(s) in https://github.com/JabRef/user-documentation/tree/main/en.

@koppor koppor requested a review from subhramit November 6, 2025 23:20
@palukku

palukku commented Nov 7, 2025

Copy link
Copy Markdown
Member

I tried running it with a valid and an completely invalid doi 1234test as two arguments and it threw an error:

Unmatched argument at index 2: '1abref'
Usage: jabkit doi-to-bibtex DOI...
Converts a DOI to BibTeX
      DOI...   one or more DOIs to fetch

But I would say it should not completely "crash" but print out the valid one and for the second the Could not fetch DOI from BibTeX.

@subhramit subhramit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Micro comments - I am committed to not letting vars enter again - so keeping them only in the example file

Comment thread jabkit/src/main/java/org/jabref/cli/DoiToBibtex.java Outdated
Comment thread jabkit/src/main/java/org/jabref/cli/DoiToBibtex.java Outdated
@palukku

palukku commented Nov 7, 2025

Copy link
Copy Markdown
Member

And maybe also a option which disables the error messages but still returns exit code 1, so if you want to work with the output and ignore errors for example. Can't name a case for that, but i can imagine that it could be helpful.

But one could probably just read the out and ignore err output and achieve it without the extra option

@koppor

koppor commented Nov 9, 2025

Copy link
Copy Markdown
Member Author

Micro comments - I am committed to not letting vars enter again - so keeping them only in the example file

We should create an architecture test for that ^^

koppor and others added 3 commits November 9, 2025 16:09
Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
@koppor

koppor commented Nov 9, 2025

Copy link
Copy Markdown
Member Author

It's far from perfect... Even with --porcelain we get some error output.

Needs to be more thought how we deal with --porcelain

I tried with

doi-to-bibtex --porcelain abc 10:333 10.47397/tb/44-3/tb138kopp-jabref

Result:

2025-11-09 16:12:37 [main] org.jabref.logic.preferences.JabRefCliPreferences.getFetcherKeysFromKeyring()
WARN: JabRef could not open the key store
2025-11-09 16:12:39 [main] org.jabref.logic.journals.JournalAbbreviationLoader.loadRepository()
INFO: Loaded journal abbreviations from C:\Users\olive\AppData\Local\Temp\jabref-journal831676151345966999\journal-list.mv
2025-11-09 16:12:39 [main] org.jabref.cli.DoiToBibtex.call()
WARN: Skipped DOI abc, because it is not a valid DOI string
2025-11-09 16:12:40 [main] org.jabref.logic.net.URLDownload.openConnection()
INFO: https://api.crossref.org/works/10:333: SimpleHttpResponse{statusCode=404, responseMessage='Not Found', responseBody='Resource not found.'}
2025-11-09 16:12:40 [main] org.jabref.cli.DoiToBibtex.call()
ERROR: Could not fetch DOI from BibTeX: org.jabref.logic.importer.FetcherClientException: 
	at org.jabref.jablib/org.jabref.logic.net.URLDownload.openConnection(URLDownload.java:389)
	at org.jabref.jablib/org.jabref.logic.net.URLDownload.asInputStream(URLDownload.java:279)
	at org.jabref.jablib/org.jabref.logic.importer.IdBasedParserFetcher.performSearchById(IdBasedParserFetcher.java:50)
	at org.jabref.jabkit/org.jabref.cli.DoiToBibtex.call(DoiToBibtex.java:49)
	at org.jabref.jabkit/org.jabref.cli.DoiToBibtex.call(DoiToBibtex.java:25)
	at info.picocli@4.7.7/picocli.CommandLine.executeUserObject(CommandLine.java:2031)
	at info.picocli@4.7.7/picocli.CommandLine.access$1500(CommandLine.java:148)
	at info.picocli@4.7.7/picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2469)
	at info.picocli@4.7.7/picocli.CommandLine$RunLast.handle(CommandLine.java:2461)
	at info.picocli@4.7.7/picocli.CommandLine$RunLast.handle(CommandLine.java:2423)
	at info.picocli@4.7.7/picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
	at info.picocli@4.7.7/picocli.CommandLine$RunLast.execute(CommandLine.java:2425)
	at info.picocli@4.7.7/picocli.CommandLine.execute(CommandLine.java:2174)
	at org.jabref.jabkit/org.jabref.JabKit.main(JabKit.java:99)
ERROR: Could not fetch DOI from BibTeX: org.jabref.logic.importer.FetcherClientException: 

@Article{,
  author    = {Oliver Kopp and Carl Christian Snethlage and Christoph Schwentker},
  title     = {JabRef: BibTeX-based literature management software},
  doi       = {10.47397/tb/44-3/tb138kopp-jabref},
  issn      = {0896-3207},
  number    = {3},
  pages     = {441-447},
  volume    = {44},
  journal   = {TUGboat},
  publisher = {TeX Users Group},
  year      = {2023},
}

@koppor koppor requested a review from palukku November 9, 2025 15:16
@koppor

koppor commented Nov 9, 2025

Copy link
Copy Markdown
Member Author

And maybe also a option which disables the error messages but still returns exit code 1, so if you want to work with the output and ignore errors for example. Can't name a case for that, but i can imagine that it could be helpful.

This is what --porcelain is useful for.

But one could probably just read the out and ignore err output and achieve it without the extra option

This is the intention of this PR ^^

@koppor koppor removed the request for review from palukku November 9, 2025 15:16
Comment thread CHANGELOG.md Outdated
Comment thread jabkit/src/main/java/org/jabref/cli/DoiToBibtex.java Outdated
@koppor

koppor commented Nov 9, 2025

Copy link
Copy Markdown
Member Author

OK, --porcelain also fixed. Did not want to add new localization, re-used as much as possible.

DOI abc is invalid

No data was found for the identifier - 10:333
URL: https://api.crossref.org/works/10:333
HTTP 404 Not Found
Resource not found.

@Article{,
  author    = {Oliver Kopp and Carl Christian Snethlage and Christoph Schwentker},
  title     = {JabRef: BibTeX-based literature management software},
  doi       = {10.47397/tb/44-3/tb138kopp-jabref},
  issn      = {0896-3207},
  number    = {3},
  pages     = {441-447},
  volume    = {44},
  journal   = {TUGboat},
  publisher = {TeX Users Group},
  year      = {2023},
}

@koppor koppor requested a review from subhramit November 9, 2025 19:53
Comment thread jabkit/src/main/java/org/jabref/cli/DoiToBibtex.java Outdated
subhramit
subhramit previously approved these changes Nov 9, 2025
@subhramit

Copy link
Copy Markdown
Member

ah some ci checks

@koppor

koppor commented Nov 9, 2025

Copy link
Copy Markdown
Member Author

ah some ci checks

 > Compilation failed; see the compiler output below.
  /home/runner/work/jabref/jabref/jabsrv/src/main/java/module-info.java:63: error: module not found: tools.jackson.databind
      requires tools.jackson.databind;
                            ^

Refs #14259 maybe

@koppor

koppor commented Nov 9, 2025

Copy link
Copy Markdown
Member Author

Somehow jackson was updated in main - and jabsrv does not compile any more.

@koppor

koppor commented Nov 9, 2025

Copy link
Copy Markdown
Member Author

Commit breaking main 32ce0b9

@koppor koppor requested a review from subhramit November 9, 2025 20:56
@koppor koppor enabled auto-merge November 9, 2025 20:56
@koppor koppor added this pull request to the merge queue Nov 9, 2025
Merged via the queue into main with commit 59355d2 Nov 9, 2025
50 checks passed
@koppor koppor deleted the add-doi-to-bibtex-example branch November 9, 2025 21:27
Siedlerchr added a commit that referenced this pull request Nov 10, 2025
* main:
  Fix calling JBang command (#14282)
  .jbang scripts should not be included inside themselves (#14278)
  Fix typos (#14277)
  Refactor importDatabase for better readability (#14274)
  fix jbang (#14276)
  Feat: Add definition links for TeX Files (#14260)
  Update preventing module commits (#14273)
  Fix JabKitLuancher
  Rename packages in jabkit to start with org.jabref.toolkit to avoid split packages between jabkit and jabgui (#14052). (#14271)
  Add doi-to-bibtex to examples and JabKit (#14244)
@koppor koppor mentioned this pull request Nov 13, 2025
2 tasks
merlinymy pushed a commit to merlinymy/jabref that referenced this pull request Nov 19, 2025
* Simplyfy code

* Fix step ignore

* Add doi_to_bibtex.java

* Add doi-to-bibtex to JabKit

* Add CHANGELOG.md entry

* Add some debug code (again)

* Fix formatting

* Fix logger

* Also deal with jabkit

* Remove debug

* Fix casing

* Fix condition

* Continue on wrong DOI

* Apply suggestions from code review

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>

* Fix checkstyle

* Fix space

* Disable JUL output at JabKit

* --porcelain does not output any logs to the console any more

* Fix logger config

* Have --porcelain working

* Improve strings

* Update CHANGELOG.md

* Update jabkit/src/main/java/org/jabref/cli/DoiToBibtex.java

* Workaround for tests

* Compilefix

---------

Co-authored-by: Subhramit Basu <subhramit.bb@live.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants