-
-
Save jcfandino/2009afa9ce1c8f8ccf365d35f4fe18c7 to your computer and use it in GitHub Desktop.
jlink example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$1" == "linux" ]; then | |
JAVA_HOME=/usr/lib/jvm/java-16 | |
RUNNER=abyss.sh | |
PLATFORM=linux | |
elif [ "$1" == "windows" ]; then | |
JAVA_HOME=jdks/jdk-16-windows | |
RUNNER=abyss.bat | |
PLATFORM=windows | |
else | |
echo "Usage $0 platform" | |
exit 1 | |
fi | |
APP_NAME=AbyssOfTheVoid | |
TARGET=$PLATFORM/$APP_NAME | |
JAR=../app/target/abyss-of-the-void.jar | |
if [ ! -f "$RUNNER" ]; then | |
echo Cannot find runner script | |
exit 1 | |
fi | |
if [ ! -f $JAR ]; then | |
echo Cannot find jar | |
exit 1 | |
fi | |
if [ ! -d $JAVA_HOME ]; then | |
echo Cannot find JDK | |
exit 1 | |
fi | |
rm -rf $TARGET | |
jlink \ | |
--strip-debug --no-header-files --no-man-pages \ | |
--module-path $JAVA_HOME/jmods \ | |
--add-modules \ | |
"java.base,java.compiler,java.datatransfer,java.desktop,java.logging,java.management,java.naming,java.prefs,java.scripting,java.xml,jdk.unsupported" \ | |
--output $TARGET | |
if [ ! -d $TARGET ]; then | |
echo Failed to jlink | |
exit 1 | |
fi | |
mkdir $TARGET/app | |
cp $JAR $TARGET/app | |
cp $RUNNER $TARGET/ | |
chmod a+x $TARGET/$RUNNER | |
ZIP_NAME=${APP_NAME}-${PLATFORM}.zip | |
pushd $PLATFORM | |
zip -r $ZIP_NAME $APP_NAME | |
popd | |
ZIP_PATH=$PLATFORM/$ZIP_NAME | |
if [ ! -f $ZIP_PATH ]; then | |
echo Failed to zip | |
exit 1 | |
fi | |
mv $ZIP_PATH . | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment