mirror of
git://f0xx.org/ac/ac-session-studio
synced 2026-07-29 06:18:35 +03:00
session-studio: runnable jar — shadow fat jar + module-path launcher + wrapper script
- Launcher.java: non-Application Main-Class entry point (bypasses JVM Application subclass check) - build.gradle: shadow plugin 8.1.1 for fat jar; startScripts patched with --module-path \$APP_HOME/lib + --add-modules; generateWrapper task writes project-root ./ac-session-studio script - ac-session-studio: generated launcher wrapper (./ac-session-studio to run) java -jar build/libs/ac-session-studio.jar still requires --module-path; use ./ac-session-studio instead Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
4
ac-session-studio
Executable file
4
ac-session-studio
Executable file
@@ -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" "$@"
|
||||||
49
build.gradle
49
build.gradle
@@ -1,6 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'application'
|
id 'application'
|
||||||
id 'org.openjfx.javafxplugin' version '0.1.0'
|
id 'org.openjfx.javafxplugin' version '0.1.0'
|
||||||
|
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -22,6 +23,54 @@ application {
|
|||||||
mainClass = 'com.foxx.androidcast.studio.SessionStudioApp'
|
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 {
|
dependencies {
|
||||||
implementation 'org.json:json:20240303'
|
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
|
||||||
|
|||||||
19
src/main/java/com/foxx/androidcast/studio/Launcher.java
Normal file
19
src/main/java/com/foxx/androidcast/studio/Launcher.java
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user