hammer-editor/snap/snapcraft.yaml
2026-06-23 10:10:05 -07:00

88 lines
3.3 KiB
YAML

name: hammer-editor
base: core22
version: '3.4.2'
summary: A simple tool for building stories
description: |
Hammer is a multi-platform story editor application. It's designed for
novelists and storytellers who want an offline-first writing experience
with optional self-hosted synchronization.
icon: snap/gui/hammer-editor-store.png
grade: stable
confinement: strict
architectures:
- build-on: amd64
apps:
hammer-editor:
command: bin/hammer
extensions: [ gnome ]
plugs:
- home
- network
- network-bind
- desktop
- desktop-legacy
- wayland
- x11
- opengl
- removable-media
parts:
hammer:
plugin: nil
source: .
build-packages:
- wget
override-build: |
set -euo pipefail
# Download and setup JetBrains Runtime SDK (full JDK with jlink/jpackage)
# createDistributable bundles whatever JVM is in JAVA_HOME, so any
# silent fall-through to the container's OpenJDK ships a non-JBR
# runtime and the app crashes on startup with the Nucleus check.
echo "Downloading JetBrains Runtime SDK..."
wget https://cache-redirector.jetbrains.com/intellij-jbr/jbrsdk_jcef-21.0.9-linux-x64-b1163.86.tar.gz
tar -xzf jbrsdk_jcef-21.0.9-linux-x64-b1163.86.tar.gz
export JAVA_HOME=$PWD/jbrsdk_jcef-21.0.9-linux-x64-b1163.86
export PATH=$JAVA_HOME/bin:$PATH
# Fail fast if the JBR SDK extract didn't produce a usable toolchain.
test -x "$JAVA_HOME/bin/java"
test -x "$JAVA_HOME/bin/jlink"
test -x "$JAVA_HOME/bin/jpackage"
echo "Building with JBR SDK (JAVA_HOME=$JAVA_HOME)"
java -version
# Run gradle build with createDistributable
# This will now bundle JBR (not OpenJDK) in lib/runtime/
chmod +x ./gradlew
# First build all necessary JARs, then create the distributable
./gradlew :desktop:jvmJar --no-daemon
./gradlew :desktop:createDistributable -x desktopTest --no-daemon
# Copy the gradle output to the install directory
# Note: outputBaseDir is set to 'installers' in build.gradle.kts
# This includes the bundled JBR at lib/runtime/
mkdir -p $CRAFT_PART_INSTALL/lib
cp -r desktop/build/installers/main/app/hammer $CRAFT_PART_INSTALL/lib/hammer
# Create the bin directory and launcher script
# Use the bundled JBR runtime instead of system OpenJDK
mkdir -p $CRAFT_PART_INSTALL/bin
cat > $CRAFT_PART_INSTALL/bin/hammer << 'EOF'
#!/bin/bash
# Use the bundled JetBrains Runtime (JBR) that comes with the distributable
export JAVA_HOME=$SNAP/lib/hammer/lib/runtime
export PATH=$JAVA_HOME/bin:$PATH
exec $SNAP/lib/hammer/bin/hammer "$@"
EOF
chmod +x $CRAFT_PART_INSTALL/bin/hammer
desktop-entry:
plugin: dump
source: snap/gui
organize:
hammer-editor.desktop: usr/share/applications/hammer-editor.desktop
hammer-editor.png: usr/share/icons/hicolor/256x256/apps/hammer-editor.png