A Gradle plugin which makes distribution zips runnable, as a sort of alternative to an uberjar. A London Beach production 💂♂️🌴.
To build:
./gradlew build
To use:
The plugin is published on the Gradle Plugin Portal, so with a modern version of Gradle, you can write:
plugins {
id 'java'
id 'application'
id 'io.pivotal.labs.exedist' version '1.0.0'
}
With the plugin applied, you gain an executableDistZip
task which makes an executable version of the distribution zip. So you can do:
./gradlew executableDistZip
./build/distributions/myapp-exe.zip
The executable zip requires a POSIX-compliant shell at /bin/sh (bash and dash are both fine), and an unzip command somewhere on the path. It runs the start script that Gradle builds, which may impose requirements of its own.
Command-line arguments to the zip are passed on to the start script, and thence to the application. The start script will also use the contents of a JAVA_OPTS
or <APPNAME>_OPTS
environment variable as arguments to the Java command.
The zip exec’s the start script, which in turn exec’s the Java command, so the application ultimately runs with the PID initially assigned to the executable zip.