Created
February 26, 2018 16:53
-
-
Save wheelerlaw/714d1ed947ccb0da0b596de7420dabe9 to your computer and use it in GitHub Desktop.
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
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2' | |
} | |
} | |
apply plugin: com.github.jengelman.gradle.plugins.shadow.ShadowPlugin | |
shadowJar { | |
baseName = "${rootProject.name}-all" | |
classifier = null | |
version = null | |
} | |
shadowDistZip { | |
archiveName rootProject.name + '.zip' | |
} | |
shadowDistTar { | |
archiveName rootProject.name + '.tar' | |
} | |
task executable(dependsOn: shadowJar) { | |
def jarName = shadowJar.archiveName | |
def startupScript = '''#!/usr/bin/env bash | |
JAVA_HOME="${JAVA_HOME:-/opt/jdk1.8.0_66/}" | |
exec $JAVA_HOME/bin/java -jar $0 "$@" | |
''' | |
doLast { | |
def jar = file("$buildDir/libs/$jarName") | |
file("$buildDir/bins").mkdirs() | |
def bin = file("$buildDir/bins/${rootProject.name}") | |
bin.text = startupScript | |
bin.setExecutable(true) | |
def input = jar.newDataInputStream() | |
bin.append(input) | |
input.close() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment