1*1b2d298cSOwner Cleanup Bot#!/usr/bin/env sh 2*1b2d298cSOwner Cleanup Bot 3*1b2d298cSOwner Cleanup Bot############################################################################## 4*1b2d298cSOwner Cleanup Bot## 5*1b2d298cSOwner Cleanup Bot## Gradle start up script for UN*X 6*1b2d298cSOwner Cleanup Bot## 7*1b2d298cSOwner Cleanup Bot############################################################################## 8*1b2d298cSOwner Cleanup Bot 9*1b2d298cSOwner Cleanup Bot# Attempt to set APP_HOME 10*1b2d298cSOwner Cleanup Bot# Resolve links: $0 may be a link 11*1b2d298cSOwner Cleanup BotPRG="$0" 12*1b2d298cSOwner Cleanup Bot# Need this for relative symlinks. 13*1b2d298cSOwner Cleanup Botwhile [ -h "$PRG" ] ; do 14*1b2d298cSOwner Cleanup Bot ls=`ls -ld "$PRG"` 15*1b2d298cSOwner Cleanup Bot link=`expr "$ls" : '.*-> \(.*\)$'` 16*1b2d298cSOwner Cleanup Bot if expr "$link" : '/.*' > /dev/null; then 17*1b2d298cSOwner Cleanup Bot PRG="$link" 18*1b2d298cSOwner Cleanup Bot else 19*1b2d298cSOwner Cleanup Bot PRG=`dirname "$PRG"`"/$link" 20*1b2d298cSOwner Cleanup Bot fi 21*1b2d298cSOwner Cleanup Botdone 22*1b2d298cSOwner Cleanup BotSAVED="`pwd`" 23*1b2d298cSOwner Cleanup Botcd "`dirname \"$PRG\"`/" >/dev/null 24*1b2d298cSOwner Cleanup BotAPP_HOME="`pwd -P`" 25*1b2d298cSOwner Cleanup Botcd "$SAVED" >/dev/null 26*1b2d298cSOwner Cleanup Bot 27*1b2d298cSOwner Cleanup BotAPP_NAME="Gradle" 28*1b2d298cSOwner Cleanup BotAPP_BASE_NAME=`basename "$0"` 29*1b2d298cSOwner Cleanup Bot 30*1b2d298cSOwner Cleanup Bot# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31*1b2d298cSOwner Cleanup BotDEFAULT_JVM_OPTS="" 32*1b2d298cSOwner Cleanup Bot 33*1b2d298cSOwner Cleanup Bot# Use the maximum available, or set MAX_FD != -1 to use that value. 34*1b2d298cSOwner Cleanup BotMAX_FD="maximum" 35*1b2d298cSOwner Cleanup Bot 36*1b2d298cSOwner Cleanup Botwarn () { 37*1b2d298cSOwner Cleanup Bot echo "$*" 38*1b2d298cSOwner Cleanup Bot} 39*1b2d298cSOwner Cleanup Bot 40*1b2d298cSOwner Cleanup Botdie () { 41*1b2d298cSOwner Cleanup Bot echo 42*1b2d298cSOwner Cleanup Bot echo "$*" 43*1b2d298cSOwner Cleanup Bot echo 44*1b2d298cSOwner Cleanup Bot exit 1 45*1b2d298cSOwner Cleanup Bot} 46*1b2d298cSOwner Cleanup Bot 47*1b2d298cSOwner Cleanup Bot# OS specific support (must be 'true' or 'false'). 48*1b2d298cSOwner Cleanup Botcygwin=false 49*1b2d298cSOwner Cleanup Botmsys=false 50*1b2d298cSOwner Cleanup Botdarwin=false 51*1b2d298cSOwner Cleanup Botnonstop=false 52*1b2d298cSOwner Cleanup Botcase "`uname`" in 53*1b2d298cSOwner Cleanup Bot CYGWIN* ) 54*1b2d298cSOwner Cleanup Bot cygwin=true 55*1b2d298cSOwner Cleanup Bot ;; 56*1b2d298cSOwner Cleanup Bot Darwin* ) 57*1b2d298cSOwner Cleanup Bot darwin=true 58*1b2d298cSOwner Cleanup Bot ;; 59*1b2d298cSOwner Cleanup Bot MINGW* ) 60*1b2d298cSOwner Cleanup Bot msys=true 61*1b2d298cSOwner Cleanup Bot ;; 62*1b2d298cSOwner Cleanup Bot NONSTOP* ) 63*1b2d298cSOwner Cleanup Bot nonstop=true 64*1b2d298cSOwner Cleanup Bot ;; 65*1b2d298cSOwner Cleanup Botesac 66*1b2d298cSOwner Cleanup Bot 67*1b2d298cSOwner Cleanup BotCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68*1b2d298cSOwner Cleanup Bot 69*1b2d298cSOwner Cleanup Bot# Determine the Java command to use to start the JVM. 70*1b2d298cSOwner Cleanup Botif [ -n "$JAVA_HOME" ] ; then 71*1b2d298cSOwner Cleanup Bot if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72*1b2d298cSOwner Cleanup Bot # IBM's JDK on AIX uses strange locations for the executables 73*1b2d298cSOwner Cleanup Bot JAVACMD="$JAVA_HOME/jre/sh/java" 74*1b2d298cSOwner Cleanup Bot else 75*1b2d298cSOwner Cleanup Bot JAVACMD="$JAVA_HOME/bin/java" 76*1b2d298cSOwner Cleanup Bot fi 77*1b2d298cSOwner Cleanup Bot if [ ! -x "$JAVACMD" ] ; then 78*1b2d298cSOwner Cleanup Bot die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79*1b2d298cSOwner Cleanup Bot 80*1b2d298cSOwner Cleanup BotPlease set the JAVA_HOME variable in your environment to match the 81*1b2d298cSOwner Cleanup Botlocation of your Java installation." 82*1b2d298cSOwner Cleanup Bot fi 83*1b2d298cSOwner Cleanup Botelse 84*1b2d298cSOwner Cleanup Bot JAVACMD="java" 85*1b2d298cSOwner Cleanup Bot which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86*1b2d298cSOwner Cleanup Bot 87*1b2d298cSOwner Cleanup BotPlease set the JAVA_HOME variable in your environment to match the 88*1b2d298cSOwner Cleanup Botlocation of your Java installation." 89*1b2d298cSOwner Cleanup Botfi 90*1b2d298cSOwner Cleanup Bot 91*1b2d298cSOwner Cleanup Bot# Increase the maximum file descriptors if we can. 92*1b2d298cSOwner Cleanup Botif [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93*1b2d298cSOwner Cleanup Bot MAX_FD_LIMIT=`ulimit -H -n` 94*1b2d298cSOwner Cleanup Bot if [ $? -eq 0 ] ; then 95*1b2d298cSOwner Cleanup Bot if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96*1b2d298cSOwner Cleanup Bot MAX_FD="$MAX_FD_LIMIT" 97*1b2d298cSOwner Cleanup Bot fi 98*1b2d298cSOwner Cleanup Bot ulimit -n $MAX_FD 99*1b2d298cSOwner Cleanup Bot if [ $? -ne 0 ] ; then 100*1b2d298cSOwner Cleanup Bot warn "Could not set maximum file descriptor limit: $MAX_FD" 101*1b2d298cSOwner Cleanup Bot fi 102*1b2d298cSOwner Cleanup Bot else 103*1b2d298cSOwner Cleanup Bot warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104*1b2d298cSOwner Cleanup Bot fi 105*1b2d298cSOwner Cleanup Botfi 106*1b2d298cSOwner Cleanup Bot 107*1b2d298cSOwner Cleanup Bot# For Darwin, add options to specify how the application appears in the dock 108*1b2d298cSOwner Cleanup Botif $darwin; then 109*1b2d298cSOwner Cleanup Bot GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110*1b2d298cSOwner Cleanup Botfi 111*1b2d298cSOwner Cleanup Bot 112*1b2d298cSOwner Cleanup Bot# For Cygwin, switch paths to Windows format before running java 113*1b2d298cSOwner Cleanup Botif $cygwin ; then 114*1b2d298cSOwner Cleanup Bot APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115*1b2d298cSOwner Cleanup Bot CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116*1b2d298cSOwner Cleanup Bot JAVACMD=`cygpath --unix "$JAVACMD"` 117*1b2d298cSOwner Cleanup Bot 118*1b2d298cSOwner Cleanup Bot # We build the pattern for arguments to be converted via cygpath 119*1b2d298cSOwner Cleanup Bot ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120*1b2d298cSOwner Cleanup Bot SEP="" 121*1b2d298cSOwner Cleanup Bot for dir in $ROOTDIRSRAW ; do 122*1b2d298cSOwner Cleanup Bot ROOTDIRS="$ROOTDIRS$SEP$dir" 123*1b2d298cSOwner Cleanup Bot SEP="|" 124*1b2d298cSOwner Cleanup Bot done 125*1b2d298cSOwner Cleanup Bot OURCYGPATTERN="(^($ROOTDIRS))" 126*1b2d298cSOwner Cleanup Bot # Add a user-defined pattern to the cygpath arguments 127*1b2d298cSOwner Cleanup Bot if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128*1b2d298cSOwner Cleanup Bot OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129*1b2d298cSOwner Cleanup Bot fi 130*1b2d298cSOwner Cleanup Bot # Now convert the arguments - kludge to limit ourselves to /bin/sh 131*1b2d298cSOwner Cleanup Bot i=0 132*1b2d298cSOwner Cleanup Bot for arg in "$@" ; do 133*1b2d298cSOwner Cleanup Bot CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134*1b2d298cSOwner Cleanup Bot CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135*1b2d298cSOwner Cleanup Bot 136*1b2d298cSOwner Cleanup Bot if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137*1b2d298cSOwner Cleanup Bot eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138*1b2d298cSOwner Cleanup Bot else 139*1b2d298cSOwner Cleanup Bot eval `echo args$i`="\"$arg\"" 140*1b2d298cSOwner Cleanup Bot fi 141*1b2d298cSOwner Cleanup Bot i=$((i+1)) 142*1b2d298cSOwner Cleanup Bot done 143*1b2d298cSOwner Cleanup Bot case $i in 144*1b2d298cSOwner Cleanup Bot (0) set -- ;; 145*1b2d298cSOwner Cleanup Bot (1) set -- "$args0" ;; 146*1b2d298cSOwner Cleanup Bot (2) set -- "$args0" "$args1" ;; 147*1b2d298cSOwner Cleanup Bot (3) set -- "$args0" "$args1" "$args2" ;; 148*1b2d298cSOwner Cleanup Bot (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149*1b2d298cSOwner Cleanup Bot (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150*1b2d298cSOwner Cleanup Bot (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151*1b2d298cSOwner Cleanup Bot (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152*1b2d298cSOwner Cleanup Bot (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153*1b2d298cSOwner Cleanup Bot (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154*1b2d298cSOwner Cleanup Bot esac 155*1b2d298cSOwner Cleanup Botfi 156*1b2d298cSOwner Cleanup Bot 157*1b2d298cSOwner Cleanup Bot# Escape application args 158*1b2d298cSOwner Cleanup Botsave () { 159*1b2d298cSOwner Cleanup Bot for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160*1b2d298cSOwner Cleanup Bot echo " " 161*1b2d298cSOwner Cleanup Bot} 162*1b2d298cSOwner Cleanup BotAPP_ARGS=$(save "$@") 163*1b2d298cSOwner Cleanup Bot 164*1b2d298cSOwner Cleanup Bot# Collect all arguments for the java command, following the shell quoting and substitution rules 165*1b2d298cSOwner Cleanup Boteval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166*1b2d298cSOwner Cleanup Bot 167*1b2d298cSOwner Cleanup Bot# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168*1b2d298cSOwner Cleanup Botif [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169*1b2d298cSOwner Cleanup Bot cd "$(dirname "$0")" 170*1b2d298cSOwner Cleanup Botfi 171*1b2d298cSOwner Cleanup Bot 172*1b2d298cSOwner Cleanup Botexec "$JAVACMD" "$@" 173