Skip to content

Fix JabRef-post-image.wsf to make it agnostic to the location of the … #13033

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 31 additions & 5 deletions jabgui/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.apache.tools.ant.filters.ReplaceTokens
import org.gradle.internal.os.OperatingSystem

plugins {
Expand Down Expand Up @@ -172,7 +173,32 @@ tasks.named("jlinkZip") {
}

tasks.register<Delete>("deleteInstallerTemp") {
delete(file("${layout.buildDirectory.get()}/installer"))
delete(layout.buildDirectory.dir("installer"))
}

var jpackageResourceDir: String = ""

if (OperatingSystem.current().isWindows) {
jpackageResourceDir = "${layout.buildDirectory.get().asFile}/jpackage-resource-dir"

tasks.register<Copy>("copyJPackageResourceDir") {
from("${projectDir}/buildres/windows") {
include("JabRef-post-image.wsf")
filter<ReplaceTokens>(mapOf("jabRefRoot" to "$projectDir".replace('\\', '/')))
}
from("${projectDir}/buildres/windows") {
exclude("JabRef-post-image.wsf")
}
into(jpackageResourceDir)
}

tasks.named("jpackage").configure {
dependsOn("copyJPackageResourceDir")
}
} else if (OperatingSystem.current().isLinux) {
jpackageResourceDir = "${projectDir}/buildres/linux"
} else if (OperatingSystem.current().isMacOsX) {
jpackageResourceDir = "${projectDir}/buildres/mac"
}

jlink {
Expand Down Expand Up @@ -259,7 +285,7 @@ jlink {
requires("org.freedesktop.dbus")
requires("org.jsoup")
requires("org.slf4j")
requires("org.tukaani.xz");
requires("org.tukaani.xz")

uses("ai.djl.engine.EngineProvider")
uses("ai.djl.repository.RepositoryFactory")
Expand Down Expand Up @@ -313,7 +339,7 @@ jlink {
"--win-menu",
"--win-menu-group", "JabRef",
"--temp", "${layout.buildDirectory.get()}/installer",
"--resource-dir", "$projectDir/buildres/windows",
"--resource-dir", jpackageResourceDir,
"--license-file", "$projectDir/buildres/LICENSE_with_Privacy.md",
"--file-associations", "$projectDir/buildres/windows/bibtexAssociations.properties"
)
Expand All @@ -332,7 +358,7 @@ jlink {
"--vendor", "JabRef",
"--app-version", "$version",
// "--temp", "$buildDir/installer",
"--resource-dir", "$projectDir/buildres/linux",
"--resource-dir", jpackageResourceDir,
"--linux-menu-group", "Office;",
"--linux-rpm-license-type", "MIT",
// "--license-file", "$projectDir/LICENSE.md",
Expand All @@ -359,7 +385,7 @@ jlink {
"--mac-package-name", "JabRef",
"--app-version", "$version",
"--file-associations", "$projectDir/buildres/mac/bibtexAssociations.properties",
"--resource-dir", "$projectDir/buildres/mac"
"--resource-dir", jpackageResourceDir
)
)
}
Expand Down
40 changes: 40 additions & 0 deletions jabgui/buildres/windows/JabRef-post-image.wsf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" ?>
<package>
<job id="postImage">
<script language="jscript">
<![CDATA[
var fileSystem = new ActiveXObject("Scripting.FileSystemObject");

// The script is invoked in the "image" folder and not in "config" for some reason
// DEBUG Output
// var shell = new ActiveXObject("WScript.Shell");
// shell.Popup(fileSystem.GetFolder("."));
var jabRefRoot = fileSystem.GetFolder('@jabRefRoot@');
// jpackage will run a copy of the script from the "config" directory.
var installerConfig = fileSystem.GetFile(WScript.ScriptFullName).ParentFolder;

WScript.Echo("jabRefRoot: " + jabRefRoot)
WScript.Echo("installerConfig: " + installerConfig)

// Copy additional installer resources
fileSystem.CopyFile(jabRefRoot + "/buildres/windows/JabRefTopBanner.bmp", installerConfig + "/JabRefTopBanner.bmp");

var wxsFilePath = installerConfig + "/main.wxs";
wxsFile = fileSystem.OpenTextFile(wxsFilePath, 1);
var contents = wxsFile.ReadAll();
wxsFile.Close();

// Add registry values for JabRef Browser Extension
contents = contents.replace("</Product>", "<DirectoryRef Id=\"TARGETDIR\"><Component Id=\"RegistryJabRefBrowserEntries\" 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=\"[INSTALLDIR]jabref-firefox.json\"/></RegistryKey><RegistryKey Root=\"HKMU\" Key=\"Software\\Google\\Chrome\\NativeMessagingHosts\\org.jabref.jabref\" Action=\"createAndRemoveOnUninstall\" ForceCreateOnInstall=\"yes\"><RegistryValue Type=\"string\" Value=\"[INSTALLDIR]jabref-chrome.json\"/></RegistryKey><RegistryKey Root=\"HKMU\" Key=\"Software\\Microsoft\\Edge\\NativeMessagingHosts\\org.jabref.jabref\" Action=\"createAndRemoveOnUninstall\" ForceCreateOnInstall=\"yes\"><RegistryValue Type=\"string\" Value=\"[INSTALLDIR]jabref-chrome.json\"/></RegistryKey><RegistryKey Root=\"HKMU\" Key=\"Software\\Google\\Chrome\\Extensions\\bifehkofibaamoeaopjglfkddgkijdlh\" Action=\"createAndRemoveOnUninstall\" ForceCreateOnInstall=\"yes\"><RegistryValue Type=\"string\" Name=\"update_url\" Value=\"https://clients2.google.com/service/update2/crx\" /></RegistryKey><RegistryKey Root=\"HKMU\" Key=\"Software\\Wow6432Node\\Google\\Chrome\\Extensions\\bifehkofibaamoeaopjglfkddgkijdlh\" Action=\"createAndRemoveOnUninstall\" ForceCreateOnInstall=\"yes\"><RegistryValue Type=\"string\" Name=\"update_url\" Value=\"https://clients2.google.com/service/update2/crx\" /></RegistryKey><RegistryKey Root=\"HKMU\" Key=\"Software\\Microsoft\\Edge\\Extensions\\pgkajmkfgbehiomipedjhoddkejohfna\" Action=\"createAndRemoveOnUninstall\" ForceCreateOnInstall=\"yes\"><RegistryValue Type=\"string\" Name=\"update_url\" Value=\"https://edge.microsoft.com/extensionwebstorebase/v1/crx\" /></RegistryKey><RegistryKey Root=\"HKMU\" Key=\"Software\\Wow6432Node\\Microsoft\\Edge\\Extensions\\pgkajmkfgbehiomipedjhoddkejohfna\" Action=\"createAndRemoveOnUninstall\" ForceCreateOnInstall=\"yes\"><RegistryValue Type=\"string\" Name=\"update_url\" Value=\"https://edge.microsoft.com/extensionwebstorebase/v1/crx\" /></RegistryKey></Component></DirectoryRef><Feature Id=\"BrowserExtension\" Level=\"1\"><ComponentRef Id=\"RegistryJabRefBrowserEntries\" /></Feature></Product>");

// Specify banner
contents = contents.replace("</Product>", "<WixVariable Id=\"WixUIBannerBmp\" Value=\"JabRefTopBanner.bmp\" /></Product>");
//contents = contents.replace("</Product>", "<WixVariable Id=\"WixUIDialogBmp\" Value=\"\" /></Product>");

wxsFile = fileSystem.OpenTextFile(wxsFilePath, 2, true);
wxsFile.Write(contents);
wxsFile.Close();
]]>
</script>
</job>
</package>
165 changes: 0 additions & 165 deletions jabgui/buildres/windows/main.wxs

This file was deleted.

Loading