Skip to content

Commit

Permalink
Generate an executable via GraalVM ⚡
Browse files Browse the repository at this point in the history
Install GraalVM (https://www.graalvm.org/) via SDKMAN! (https://sdkman.io/).

GraalVM is used to build a native image (executable) from the fat JAR.

Note: 'libsunec' native library (Sun Elliptic Curve crypto) needs to be in java.library.path, it is copied in current directory).
  • Loading branch information
nicokosi committed Apr 9, 2019
1 parent 5b7a913 commit 283b305
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,5 @@ gradle-app.setting

# End of https://www.gitignore.io/api/gradle,kotlin,eclipse,intellij,visualstudiocode
/.idea/sonarIssues.xml
/pullpitoK
/libsunec.*
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ In order to show the 'usage':

./gradlew run --args "--help"

## Install

In order to generate a *nix executable, run:

./generate-executable.sh

An executable file named `pullpitoK` should be generated in the current directory. It can then be run:

./pullpitoK

## Upgrade dependencies

./gradlew useLatestVersions
29 changes: 29 additions & 0 deletions generate-executable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Fail on error
set -e

echo "Build nicokosi/pullpitoK JAR file:"
./gradlew shadowJar

echo "Install GraalVM via SDKMAN!:"
curl -s "https://get.sdkman.io" | bash || echo 'SDKMAN! already installed'
source "$HOME/.sdkman/bin/sdkman-init.sh"
GRAALVM_VERSION=1.0.0-rc-15-grl
sdk install java $GRAALVM_VERSION
sdk use java $GRAALVM_VERSION

echo "Copy 'libsunec' shared library (Sun Elliptic Curve crypto):"
cp $JAVA_HOME/jre/lib/libsunec* .

echo "Build nicokosi/pullpitoK's executable from JAR via GraalVM:"
native-image \
--no-server \
--verbose \
--enable-https \
-jar ./build/libs/pullpitoK-all.jar \
pullpitoK && \
echo ' => Check the executable: ' && ./pullpitoK

echo "Executable has been generated, try it copy/pasting this command:"
echo " GRAALVM_HOME=$GRAALVM_HOME ./pullpitoK python/peps"
2 changes: 2 additions & 0 deletions src/main/kotlin/pullpitok/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import pullpitok.github.Type

fun main(args: Array<String>) {

System.setProperty("java.library.path", System.getenv("GRAALVM_HOME") + "/jre/lib")

if (!checkArgs(args)) System.exit(0)
val repo = args[0]
val token = args.getOrNull(1) ?: ""
Expand Down

0 comments on commit 283b305

Please sign in to comment.