Skip to content

Commit 8dd3fab

Browse files
authored
Merge pull request #5400 from JabRef/fixJabfoxInstall
Fix JabFox integration
2 parents facda00 + a6948ea commit 8dd3fab

7 files changed

+59
-17
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
2222
- We fixed an issue where it was no longer possible to connect to LibreOffice. [#5261](https://github.com/JabRef/jabref/issues/5261)
2323
- The "All entries group" is no longer shown when no library is open.
2424
- We fixed an exception which occurred when closing JabRef. [#5348](https://github.com/JabRef/jabref/issues/5348)
25+
- We fixed a few problems that prevented JabFox to communicate with JabRef. [#4737](https://github.com/JabRef/jabref/issues/4737) [#4303](https://github.com/JabRef/jabref/issues/4303)
2526
- We fixed an error where the groups containing an entry loose their highlight color when scrolling. [#5022](https://github.com/JabRef/jabref/issues/5022)
2627
- We fixed an error where an exception was thrown when merging entries. [#5169](https://github.com/JabRef/jabref/issues/5169)
2728
- After assigning an entry to a group, the item count is now properly colored to reflect the new membership of the entry. [#3112](https://github.com/JabRef/jabref/issues/3112)

build.gradle

+14-7
Original file line numberDiff line numberDiff line change
@@ -507,14 +507,11 @@ modernizer {
507507
}
508508

509509
// Release tasks
510-
task generateFinalJabRefPS1File(type: Copy) {
511-
from('buildres') {
512-
include 'JabRef.ps1'
513-
}
514-
into 'build'
515-
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [jabRefJarFileName: jar.archiveName])
510+
task deleteInstallerTemp(type: Delete) {
511+
delete "$buildDir/installer"
516512
}
517513

514+
jpackage.dependsOn deleteInstallerTemp
518515
jlink {
519516
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
520517
launcher {
@@ -585,7 +582,9 @@ jlink {
585582
'--app-version', "${project.version}",
586583
'--win-upgrade-uuid', 'd636b4ee-6f10-451e-bf57-c89656780e36',
587584
'--win-dir-chooser',
588-
'--win-shortcut'
585+
'--win-shortcut',
586+
'--temp', "$buildDir/installer",
587+
'--resource-dir', "${projectDir}/buildres"
589588
]
590589
}
591590

@@ -610,6 +609,14 @@ jlink {
610609
}
611610
}
612611
}
612+
tasks.jpackageImage.doLast {
613+
copy {
614+
from("/buildres/") {
615+
include "jabref.json", "JabRefHost.bat", "JabRefHost.ps1"
616+
}
617+
into "$buildDir/distribution/JabRef"
618+
}
619+
}
613620

614621
jmh {
615622
warmupIterations = 5

buildres/JabRef-post-image.wsf

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" ?>
2+
<package>
3+
<job id="postImage">
4+
<script language="jscript">
5+
<![CDATA[
6+
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");
7+
// The script is invoked in the "image" folder and not in "config" for some reason
8+
var jabRefRoot = fileSystem.GetFolder(".").ParentFolder.ParentFolder.ParentFolder.ParentFolder.Path;
9+
var installerConfig = jabRefRoot + "/build/installer/config/";
10+
11+
// Copy additional installer resources
12+
fileSystem.CopyFile(jabRefRoot + "/buildres/JabRefTopBanner.bmp", installerConfig);
13+
14+
var wxsFilePath = installerConfig + "JabRef.wxs";
15+
wxsFile = fileSystem.OpenTextFile(wxsFilePath, 1);
16+
var contents = wxsFile.ReadAll();
17+
wxsFile.Close();
18+
19+
// Add registry values for JabFox
20+
contents = contents.replace("</Product>", "<DirectoryRef Id=\"TARGETDIR\"><Component Id=\"RegistryJabFoxEntries\" Guid=\"b6bc55ad-905c-4258-89b1-8b37abbe559c\" Win64=\"yes\"><RegistryKey Root=\"HKMU\" Key=\"SOFTWARE\\Mozilla\\NativeMessagingHosts\\org.jabref.jabref\" Action=\"createAndRemoveOnUninstall\" ForceCreateOnInstall=\"yes\"><RegistryValue Type=\"string\" Value=\"[APPLICATIONFOLDER]jabref.json\"/></RegistryKey></Component></DirectoryRef><Feature Id=\"JabFox\" Level=\"1\"><ComponentRef Id=\"RegistryJabFoxEntries\" /></Feature></Product>");
21+
22+
// Specify correct icon in Add/Remove Programs
23+
contents = contents.replace("</Product>", "<Property Id=\"ARPPRODUCTICON\" Value=\"DesktopIcon.exe\" /></Product>");
24+
25+
// Specify banner
26+
contents = contents.replace("</Product>", "<WixVariable Id=\"WixUIBannerBmp\" Value=\"JabRefTopBanner.bmp\" /></Product>");
27+
//contents = contents.replace("</Product>", "<WixVariable Id=\"WixUIDialogBmp\" Value=\"\" /></Product>");
28+
29+
wxsFile = fileSystem.OpenTextFile(wxsFilePath, 2, true);
30+
wxsFile.Write(contents);
31+
wxsFile.Close();
32+
]]>
33+
</script>
34+
</job>
35+
</package>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
22
pushd %~dp0
3-
@powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File ".\JabRef.ps1"
3+
@powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File ".\JabRefHost.ps1"

buildres/JabRef.ps1 buildres/JabRefHost.ps1

+7-8
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ function Respond($response) {
1111
}
1212
}
1313

14-
$jabRefJarFileName = "@jabRefJarFileName@"
15-
$jabRefJar = [System.IO.Path]::Combine($PSScriptRoot, $jabRefJarFileName)
14+
$jabRefExe = [System.IO.Path]::Combine($PSScriptRoot, "JabRef.exe")
1615

1716
try {
1817
$reader = New-Object System.IO.BinaryReader([System.Console]::OpenStandardInput())
@@ -21,16 +20,16 @@ try {
2120
$message = $messageRaw | ConvertFrom-Json
2221

2322
if ($message.Status -eq "validate") {
24-
if (-not (Test-Path $jabRefJar)) {
25-
return Respond @{message="jarNotFound";path=$jabRefJar}
23+
if (-not (Test-Path $jabRefExe)) {
24+
return Respond @{message="jarNotFound";path=$jabRefExe}
2625
} else {
2726
return Respond @{message="jarFound"}
2827
}
2928
}
30-
31-
if (-not (Test-Path $jabRefJar)) {
29+
30+
if (-not (Test-Path $jabRefExe)) {
3231
$wshell = New-Object -ComObject Wscript.Shell
33-
$popup = "Unable to locate '$jabRefJarFileName' in '$([System.IO.Path]::GetDirectoryName($jabRefJar))'."
32+
$popup = "Unable to locate '$jabRefExe'."
3433
$wshell.Popup($popup,0,"JabRef", 0x0 + 0x30)
3534
return
3635
}
@@ -39,7 +38,7 @@ try {
3938
#$wshell.Popup($message.Text,0,"JabRef", 0x0 + 0x30)
4039

4140
$messageText = $message.Text
42-
$output = & java -jar $jabRefJar -importBibtex "$messageText" 2>&1
41+
$output = & $jabRefExe -importBibtex "$messageText" 2>&1
4342
#$output = & echoargs -importBibtex $messageText 2>&1
4443
#$wshell.Popup($output,0,"JabRef", 0x0 + 0x30)
4544
return Respond @{message="ok";output="$output"}

buildres/JabRefTopBanner.bmp

83.9 KB
Binary file not shown.

buildres/jabref.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "org.jabref.jabref",
33
"description": "JabRef",
4-
"path": "JabRef.bat",
4+
"path": "JabRefHost.bat",
55
"type": "stdio",
66
"allowed_extensions": [
77
"@jabfox"

0 commit comments

Comments
 (0)