Skip to content
Draft
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
8 changes: 6 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ jobs:
java-version: '25'
distribution: 'corretto'
- uses: gradle/actions/setup-gradle@v4
- run: ./gradlew jpackage
# See https://docs.gradle.org/current/userguide/logging.html#sec:choosing_a_log_level for the log levels
# We opted for "-i", because it outputs the commands used to build the application image
- run: ./gradlew -i jpackage
- run: ls -la /Users/runner/work/javafxreproducer/javafxreproducer/build/tmp/jpackage/macos-14/app-content/Resources
if: ${{ always() && runner.os == 'macOS' }}
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4
with:
name: javafxreproducer-${{ matrix.os }}
path: build/distributions
path: build/packages
compression-level: 0
20 changes: 20 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,24 @@ javaModulePackaging {
architecture = MachineArchitecture.X86_64
packageTypes = listOf("app-image", "msi")
}

targetsWithOs("macos") {
options.addAll(
// "--icon", "$projectDir/src/main/resources/icons/jabref.icns",
"--mac-package-identifier", "JabRef",
"--mac-package-name", "JabRef",
"--file-associations", "$projectDir/buildres/macos/bibtexAssociations.properties",
)
if (providers.environmentVariable("OSXCERT").orNull?.isNotBlank() ?: false) {
options.addAll(
"--mac-sign",
"--mac-signing-key-user-name", "JabRef e.V. (6792V39SK3)",
"--mac-package-signing-prefix", "org.jabref",
)
}
targetResources.from(layout.projectDirectory.dir("buildres/macos").asFileTree.matching {
include("Resources/**")
})
}

}
39 changes: 39 additions & 0 deletions buildres/macos/Info-lite.plist.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSMinimumSystemVersion</key>
<string>10.9</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleExecutable</key>
<string>DEPLOY_LAUNCHER_NAME</string>
<key>CFBundleIconFile</key>
<string>DEPLOY_ICON_FILE</string>
<key>CFBundleIdentifier</key>
<string>DEPLOY_BUNDLE_IDENTIFIER</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>DEPLOY_BUNDLE_NAME</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>DEPLOY_BUNDLE_SHORT_VERSION</string>
<key>CFBundleSignature</key>
<string>????</string>
<!-- See https://developer.apple.com/app-store/categories/ for list of AppStore categories -->
<key>LSApplicationCategoryType</key>
<string>Unknown</string>
<key>CFBundleVersion</key>
<string>DEPLOY_BUNDLE_CFBUNDLE_VERSION</string>
<key>NSHumanReadableCopyright</key>
<string>DEPLOY_BUNDLE_COPYRIGHT</string>DEPLOY_FILE_ASSOCIATIONS
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict>
</plist>
39 changes: 39 additions & 0 deletions buildres/macos/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSMinimumSystemVersion</key>
<string>10.9</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleExecutable</key>
<string>DEPLOY_LAUNCHER_NAME</string>
<key>CFBundleIconFile</key>
<string>DEPLOY_ICON_FILE</string>
<key>CFBundleIdentifier</key>
<string>DEPLOY_BUNDLE_IDENTIFIER</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>DEPLOY_BUNDLE_NAME</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>DEPLOY_BUNDLE_SHORT_VERSION</string>
<key>CFBundleSignature</key>
<string>????</string>
<!-- See https://developer.apple.com/app-store/categories/ for list of AppStore categories -->
<key>LSApplicationCategoryType</key>
<string>Unknown</string>
<key>CFBundleVersion</key>
<string>DEPLOY_BUNDLE_CFBUNDLE_VERSION</string>
<key>NSHumanReadableCopyright</key>
<string>DEPLOY_BUNDLE_COPYRIGHT</string>DEPLOY_FILE_ASSOCIATIONS
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict>
</plist>
39 changes: 39 additions & 0 deletions buildres/macos/Info.plist.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSMinimumSystemVersion</key>
<string>10.9</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleAllowMixedLocalizations</key>
<true/>
<key>CFBundleExecutable</key>
<string>DEPLOY_LAUNCHER_NAME</string>
<key>CFBundleIconFile</key>
<string>DEPLOY_ICON_FILE</string>
<key>CFBundleIdentifier</key>
<string>DEPLOY_BUNDLE_IDENTIFIER</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>DEPLOY_BUNDLE_NAME</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>DEPLOY_BUNDLE_SHORT_VERSION</string>
<key>CFBundleSignature</key>
<string>????</string>
<!-- See https://developer.apple.com/app-store/categories/ for list of AppStore categories -->
<key>LSApplicationCategoryType</key>
<string>Unknown</string>
<key>CFBundleVersion</key>
<string>DEPLOY_BUNDLE_CFBUNDLE_VERSION</string>
<key>NSHumanReadableCopyright</key>
<string>DEPLOY_BUNDLE_COPYRIGHT</string>DEPLOY_FILE_ASSOCIATIONS
<key>NSHighResolutionCapable</key>
<string>true</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict>
</plist>
Binary file added buildres/macos/JabRef-background-darkAqua.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buildres/macos/JabRef-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added buildres/macos/JabRef-background.tiff
Binary file not shown.
44 changes: 44 additions & 0 deletions buildres/macos/JabRef-dmg-setup.scpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
tell application "Finder"
set theDisk to a reference to (disks whose URL = "DEPLOY_VOLUME_URL")
open theDisk

set theWindow to a reference to (container window of disks whose URL = "DEPLOY_VOLUME_URL")

set current view of theWindow to icon view
set toolbar visible of theWindow to false
set statusbar visible of theWindow to false

-- size of window should fit the size of background
set the bounds of theWindow to {346, 100, 920, 500}

set theViewOptions to a reference to the icon view options of theWindow
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 128
set background picture of theViewOptions to POSIX file "DEPLOY_BG_FILE"

-- Create alias for install location
make new alias file at POSIX file "DEPLOY_VOLUME_PATH" to POSIX file "DEPLOY_INSTALL_LOCATION" with properties {name:"DEPLOY_INSTALL_LOCATION_DISPLAY_NAME"}

set allTheFiles to the name of every item of theWindow
set xpos to 120
repeat with theFile in allTheFiles
set theFilePath to POSIX path of theFile
set appFilePath to POSIX path of "/DEPLOY_TARGET"
if theFilePath ends with "DEPLOY_INSTALL_LOCATION_DISPLAY_NAME" then
-- Position install location application
set position of item theFile of theWindow to {440, 170}
else if theFilePath ends with appFilePath then
-- Position application or runtime
set position of item theFile of theWindow to {140, 170}
else
-- Position all other items in a second row.
set position of item theFile of theWindow to {xpos, 400}
set xpos to xpos + 150
end if
end repeat


update theDisk without registering applications
delay 5
close (get window of theDisk)
end tell
Binary file added buildres/macos/Jabref-volume.icns
Binary file not shown.
12 changes: 12 additions & 0 deletions buildres/macos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Mac Resources

## Modifying DMG Setup scpt

Rename `JabRef-dmg-setup.scpt script` to `JabRef-dmg-setup.applescript`.
Only modify the `JabRef-dmg-setup.applescript` in the macOS Script Editor. Afterwards copy over the file and rename it to `JabRef-dmg-setup.scpt`.
Normally the `scpt` file is a binary compiled variant and the `.applescript` the uncompiled format but jpackage expects the sctp in uncompiled format

## Generate iconsets

To generate icns files use the script under `src/main/resources/icons`
Install [svg2png](https://formulae.brew.sh/formula/svg2png) and call the script with the svg filename as first argument.
Binary file added buildres/macos/Resources/jabref.icns
Binary file not shown.
101 changes: 101 additions & 0 deletions buildres/macos/Resources/jabrefHost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/python3

import json
import logging
import platform
import shlex
import shutil
import struct
import subprocess
import sys
from pathlib import Path

# We assume that this python script is located in "jabref/lib" while the executable is "jabref/bin/JabRef"
# Note that the package structure is different when installed as a .app bundle on MacOs, so the path must be altered.
script_dir = Path(__file__).resolve().parent.parent
JABREF_PATH = script_dir / "bin/JabRef"

# on mac we must only two folder upwards
if sys.platform.startswith('darwin'):
script_dir = Path(__file__).resolve().parent.parent
if not JABREF_PATH.exists():
JABREF_PATH = script_dir / "MacOS/JabRef"

if not JABREF_PATH.exists():
logging.error("Could not determine JABREF_PATH")
send_message({"message": "error", "output": "Could not find JabRef. Please check that it is installed correctly."})
sys.exit(-1)

logging_dir = Path.home() / ".mozilla/native-messaging-hosts/"
if not logging_dir.exists():
logging_dir.mkdir(parents=True)
logging.basicConfig(filename=str(logging_dir / "jabref_browser_extension.log"))

# Read a message from stdin and decode it.
def get_message():
raw_length = sys.stdin.buffer.read(4)
if not raw_length:
logging.error("Raw_length null")
sys.exit(0)
message_length = struct.unpack("=I", raw_length)[0]
logging.info("Got length: {} bytes to be read".format(message_length))
message = sys.stdin.buffer.read(message_length).decode("utf-8")
logging.info("Got message of {} chars".format(len(message)))
data = json.loads(message)
logging.info("Successfully retrieved JSON")
return data


# Encode a message for transmission, given its content.
def encode_message(message_content):
encoded_content = json.dumps(message_content).encode("utf-8")
encoded_length = struct.pack("=I", len(encoded_content))
return {
"length": encoded_length,
"content": struct.pack(str(len(encoded_content)) + "s", encoded_content),
}


# Send an encoded message to stdout.
def send_message(message):
encoded_message = encode_message(message)
sys.stdout.buffer.write(encoded_message["length"])
sys.stdout.buffer.write(encoded_message["content"])
sys.stdout.buffer.flush()


def add_jabref_entry(data):
"""Send string via cli as literal to preserve special characters"""
cmd = str(JABREF_PATH).split() + ["--importBibtex", r"{}".format(data)]
logging.info("Try to execute command {}".format(cmd))
response = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
logging.info("Called JabRef and got: {}".format(response))
return response


logging.info("Starting JabRef backend")

try:
message = get_message()
except Exception as e:
message = str(e)
logging.info(str(message))

if "status" in message and message["status"] == "validate":
cmd = str(JABREF_PATH).split() + ["--version"]
try:
response = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
logging.error("Failed to call JabRef: {} {}".format(exc.returncode, exc.output))
send_message({"message": "jarNotFound", "path": JABREF_PATH})
else:
logging.info("Response: {}".format(response))
send_message({"message": "jarFound"})
else:
entry = message["text"]
try:
output = add_jabref_entry(entry)
send_message({"message": "ok", "output": str(output)})
except subprocess.CalledProcessError as exc:
logging.error("Failed to call JabRef: {} {}".format(exc.returncode, exc.output))
send_message({"message": "error", "output": str(exc.output)})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"external_update_url": "https://clients2.google.com/service/update2/crx"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "org.jabref.jabref",
"description": "JabRef",
"path": "/Applications/JabRef.app/Contents/Resources/jabrefHost.py",
"type": "stdio",
"allowed_origins": [
"chrome-extension://bifehkofibaamoeaopjglfkddgkijdlh/",
"chrome-extension://pgkajmkfgbehiomipedjhoddkejohfna/"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "org.jabref.jabref",
"description": "JabRef",
"path": "/Applications/JabRef.app/Contents/Resources/jabrefHost.py",
"type": "stdio",
"allowed_extensions": ["[email protected]", "@jabfox"]
}
26 changes: 26 additions & 0 deletions buildres/macos/Runtime-Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>libjli.dylib</string>
<key>CFBundleIdentifier</key>
<string>CF_BUNDLE_IDENTIFIER</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>7.0</string>
<key>CFBundleName</key>
<string>CF_BUNDLE_NAME</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>CF_BUNDLE_SHORT_VERSION_STRING</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>CF_BUNDLE_VERSION</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict>
</plist>
26 changes: 26 additions & 0 deletions buildres/macos/Runtime-Info.plist.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>libjli.dylib</string>
<key>CFBundleIdentifier</key>
<string>CF_BUNDLE_IDENTIFIER</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>7.0</string>
<key>CFBundleName</key>
<string>CF_BUNDLE_NAME</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>CF_BUNDLE_SHORT_VERSION_STRING</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>CF_BUNDLE_VERSION</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict>
</plist>
Loading
Loading