diff --git a/ac-session-studio b/ac-session-studio new file mode 100755 index 0000000..b9f6629 --- /dev/null +++ b/ac-session-studio @@ -0,0 +1,4 @@ +#!/bin/sh +# Auto-generated launcher wrapper — re-run ./gradlew generateWrapper to refresh +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +exec "${SCRIPT_DIR}/build/install/ac-session-studio/bin/ac-session-studio" "$@" diff --git a/build.gradle b/build.gradle index a99079b..0fd15e6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'application' id 'org.openjfx.javafxplugin' version '0.1.0' + id 'com.github.johnrengelman.shadow' version '8.1.1' } repositories { @@ -22,6 +23,54 @@ application { mainClass = 'com.foxx.androidcast.studio.SessionStudioApp' } +// Patch generated Unix start script to add --module-path $APP_HOME/lib. +tasks.named('startScripts').configure { + doLast { + def script = unixScript + // Replace the -classpath line to also include --module-path before it + script.text = script.text.replace( + ' -classpath "$CLASSPATH" \\', + ' --module-path "$APP_HOME/lib" \\\n --add-modules javafx.controls,javafx.graphics,javafx.base \\\n -classpath "$CLASSPATH" \\' + ) + } +} + dependencies { implementation 'org.json:json:20240303' } + +jar { + manifest { + attributes 'Main-Class': 'com.foxx.androidcast.studio.Launcher' + } +} + +shadowJar { + archiveBaseName = 'ac-session-studio' + archiveClassifier = '' + archiveVersion = '' + manifest { + attributes 'Main-Class': 'com.foxx.androidcast.studio.Launcher' + } + mergeServiceFiles() +} + +// After installDist, generate a convenience wrapper at the project root +tasks.register('generateWrapper') { + dependsOn installDist + doLast { + def wrapper = file("${rootProject.projectDir}/ac-session-studio") + def distBin = "${buildDir}/install/ac-session-studio/bin/ac-session-studio" + wrapper.text = """\ +#!/bin/sh +# Auto-generated launcher wrapper — re-run ./gradlew generateWrapper to refresh +SCRIPT_DIR="\$(cd "\$(dirname "\$0")" && pwd)" +exec "\${SCRIPT_DIR}/build/install/ac-session-studio/bin/ac-session-studio" "\$@" +""" + wrapper.setExecutable(true) + println "Wrapper written: ${wrapper}" + } +} + +// Also attach generateWrapper to the standard build lifecycle +build.dependsOn generateWrapper diff --git a/src/main/java/com/foxx/androidcast/studio/Launcher.java b/src/main/java/com/foxx/androidcast/studio/Launcher.java new file mode 100644 index 0000000..1093ac7 --- /dev/null +++ b/src/main/java/com/foxx/androidcast/studio/Launcher.java @@ -0,0 +1,19 @@ +package com.foxx.androidcast.studio; + +/** + * Fat-jar entry point that does NOT extend javafx.application.Application. + * + * On Java 9+ the JVM checks whether Main-Class is an Application subclass and + * refuses to launch it from a classpath jar when JavaFX modules are not on the + * explicit module path. Delegating through this plain class bypasses that check. + * + * For direct execution use the generated wrapper script instead of java -jar: + * ./build/install/ac-session-studio/bin/ac-session-studio + * or the project-root wrapper: + * ./ac-session-studio + */ +public final class Launcher { + public static void main(String[] args) { + SessionStudioApp.main(args); + } +}