plugins { id 'application' id 'org.openjfx.javafxplugin' version '0.1.0' id 'com.github.johnrengelman.shadow' version '8.1.1' } repositories { mavenCentral() } java { toolchain { languageVersion = JavaLanguageVersion.of(21) } } javafx { version = '21' modules = ['javafx.controls'] } 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