1cb93a386Sopenharmony_ci#!/usr/bin/env bash 2cb93a386Sopenharmony_ci 3cb93a386Sopenharmony_ci############################################################################## 4cb93a386Sopenharmony_ci## 5cb93a386Sopenharmony_ci## Gradle start up script for UN*X 6cb93a386Sopenharmony_ci## 7cb93a386Sopenharmony_ci############################################################################## 8cb93a386Sopenharmony_ci 9cb93a386Sopenharmony_ci# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10cb93a386Sopenharmony_ciDEFAULT_JVM_OPTS="" 11cb93a386Sopenharmony_ci 12cb93a386Sopenharmony_ciAPP_NAME="Gradle" 13cb93a386Sopenharmony_ciAPP_BASE_NAME=`basename "$0"` 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_ci# Use the maximum available, or set MAX_FD != -1 to use that value. 16cb93a386Sopenharmony_ciMAX_FD="maximum" 17cb93a386Sopenharmony_ci 18cb93a386Sopenharmony_ciwarn ( ) { 19cb93a386Sopenharmony_ci echo "$*" 20cb93a386Sopenharmony_ci} 21cb93a386Sopenharmony_ci 22cb93a386Sopenharmony_cidie ( ) { 23cb93a386Sopenharmony_ci echo 24cb93a386Sopenharmony_ci echo "$*" 25cb93a386Sopenharmony_ci echo 26cb93a386Sopenharmony_ci exit 1 27cb93a386Sopenharmony_ci} 28cb93a386Sopenharmony_ci 29cb93a386Sopenharmony_ci# OS specific support (must be 'true' or 'false'). 30cb93a386Sopenharmony_cicygwin=false 31cb93a386Sopenharmony_cimsys=false 32cb93a386Sopenharmony_cidarwin=false 33cb93a386Sopenharmony_cicase "`uname`" in 34cb93a386Sopenharmony_ci CYGWIN* ) 35cb93a386Sopenharmony_ci cygwin=true 36cb93a386Sopenharmony_ci ;; 37cb93a386Sopenharmony_ci Darwin* ) 38cb93a386Sopenharmony_ci darwin=true 39cb93a386Sopenharmony_ci ;; 40cb93a386Sopenharmony_ci MINGW* ) 41cb93a386Sopenharmony_ci msys=true 42cb93a386Sopenharmony_ci ;; 43cb93a386Sopenharmony_ciesac 44cb93a386Sopenharmony_ci 45cb93a386Sopenharmony_ci# For Cygwin, ensure paths are in UNIX format before anything is touched. 46cb93a386Sopenharmony_ciif $cygwin ; then 47cb93a386Sopenharmony_ci [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48cb93a386Sopenharmony_cifi 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci# Attempt to set APP_HOME 51cb93a386Sopenharmony_ci# Resolve links: $0 may be a link 52cb93a386Sopenharmony_ciPRG="$0" 53cb93a386Sopenharmony_ci# Need this for relative symlinks. 54cb93a386Sopenharmony_ciwhile [ -h "$PRG" ] ; do 55cb93a386Sopenharmony_ci ls=`ls -ld "$PRG"` 56cb93a386Sopenharmony_ci link=`expr "$ls" : '.*-> \(.*\)$'` 57cb93a386Sopenharmony_ci if expr "$link" : '/.*' > /dev/null; then 58cb93a386Sopenharmony_ci PRG="$link" 59cb93a386Sopenharmony_ci else 60cb93a386Sopenharmony_ci PRG=`dirname "$PRG"`"/$link" 61cb93a386Sopenharmony_ci fi 62cb93a386Sopenharmony_cidone 63cb93a386Sopenharmony_ciSAVED="`pwd`" 64cb93a386Sopenharmony_cicd "`dirname \"$PRG\"`/" >&- 65cb93a386Sopenharmony_ciAPP_HOME="`pwd -P`" 66cb93a386Sopenharmony_cicd "$SAVED" >&- 67cb93a386Sopenharmony_ci 68cb93a386Sopenharmony_ciCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69cb93a386Sopenharmony_ci 70cb93a386Sopenharmony_ci# Determine the Java command to use to start the JVM. 71cb93a386Sopenharmony_ciif [ -n "$JAVA_HOME" ] ; then 72cb93a386Sopenharmony_ci if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73cb93a386Sopenharmony_ci # IBM's JDK on AIX uses strange locations for the executables 74cb93a386Sopenharmony_ci JAVACMD="$JAVA_HOME/jre/sh/java" 75cb93a386Sopenharmony_ci else 76cb93a386Sopenharmony_ci JAVACMD="$JAVA_HOME/bin/java" 77cb93a386Sopenharmony_ci fi 78cb93a386Sopenharmony_ci if [ ! -x "$JAVACMD" ] ; then 79cb93a386Sopenharmony_ci die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80cb93a386Sopenharmony_ci 81cb93a386Sopenharmony_ciPlease set the JAVA_HOME variable in your environment to match the 82cb93a386Sopenharmony_cilocation of your Java installation." 83cb93a386Sopenharmony_ci fi 84cb93a386Sopenharmony_cielse 85cb93a386Sopenharmony_ci JAVACMD="java" 86cb93a386Sopenharmony_ci which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87cb93a386Sopenharmony_ci 88cb93a386Sopenharmony_ciPlease set the JAVA_HOME variable in your environment to match the 89cb93a386Sopenharmony_cilocation of your Java installation." 90cb93a386Sopenharmony_cifi 91cb93a386Sopenharmony_ci 92cb93a386Sopenharmony_ci# Increase the maximum file descriptors if we can. 93cb93a386Sopenharmony_ciif [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94cb93a386Sopenharmony_ci MAX_FD_LIMIT=`ulimit -H -n` 95cb93a386Sopenharmony_ci if [ $? -eq 0 ] ; then 96cb93a386Sopenharmony_ci if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97cb93a386Sopenharmony_ci MAX_FD="$MAX_FD_LIMIT" 98cb93a386Sopenharmony_ci fi 99cb93a386Sopenharmony_ci ulimit -n $MAX_FD 100cb93a386Sopenharmony_ci if [ $? -ne 0 ] ; then 101cb93a386Sopenharmony_ci warn "Could not set maximum file descriptor limit: $MAX_FD" 102cb93a386Sopenharmony_ci fi 103cb93a386Sopenharmony_ci else 104cb93a386Sopenharmony_ci warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105cb93a386Sopenharmony_ci fi 106cb93a386Sopenharmony_cifi 107cb93a386Sopenharmony_ci 108cb93a386Sopenharmony_ci# For Darwin, add options to specify how the application appears in the dock 109cb93a386Sopenharmony_ciif $darwin; then 110cb93a386Sopenharmony_ci GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111cb93a386Sopenharmony_cifi 112cb93a386Sopenharmony_ci 113cb93a386Sopenharmony_ci# For Cygwin, switch paths to Windows format before running java 114cb93a386Sopenharmony_ciif $cygwin ; then 115cb93a386Sopenharmony_ci APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116cb93a386Sopenharmony_ci CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117cb93a386Sopenharmony_ci 118cb93a386Sopenharmony_ci # We build the pattern for arguments to be converted via cygpath 119cb93a386Sopenharmony_ci ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120cb93a386Sopenharmony_ci SEP="" 121cb93a386Sopenharmony_ci for dir in $ROOTDIRSRAW ; do 122cb93a386Sopenharmony_ci ROOTDIRS="$ROOTDIRS$SEP$dir" 123cb93a386Sopenharmony_ci SEP="|" 124cb93a386Sopenharmony_ci done 125cb93a386Sopenharmony_ci OURCYGPATTERN="(^($ROOTDIRS))" 126cb93a386Sopenharmony_ci # Add a user-defined pattern to the cygpath arguments 127cb93a386Sopenharmony_ci if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128cb93a386Sopenharmony_ci OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129cb93a386Sopenharmony_ci fi 130cb93a386Sopenharmony_ci # Now convert the arguments - kludge to limit ourselves to /bin/sh 131cb93a386Sopenharmony_ci i=0 132cb93a386Sopenharmony_ci for arg in "$@" ; do 133cb93a386Sopenharmony_ci CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134cb93a386Sopenharmony_ci CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135cb93a386Sopenharmony_ci 136cb93a386Sopenharmony_ci if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137cb93a386Sopenharmony_ci eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138cb93a386Sopenharmony_ci else 139cb93a386Sopenharmony_ci eval `echo args$i`="\"$arg\"" 140cb93a386Sopenharmony_ci fi 141cb93a386Sopenharmony_ci i=$((i+1)) 142cb93a386Sopenharmony_ci done 143cb93a386Sopenharmony_ci case $i in 144cb93a386Sopenharmony_ci (0) set -- ;; 145cb93a386Sopenharmony_ci (1) set -- "$args0" ;; 146cb93a386Sopenharmony_ci (2) set -- "$args0" "$args1" ;; 147cb93a386Sopenharmony_ci (3) set -- "$args0" "$args1" "$args2" ;; 148cb93a386Sopenharmony_ci (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149cb93a386Sopenharmony_ci (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150cb93a386Sopenharmony_ci (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151cb93a386Sopenharmony_ci (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152cb93a386Sopenharmony_ci (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153cb93a386Sopenharmony_ci (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154cb93a386Sopenharmony_ci esac 155cb93a386Sopenharmony_cifi 156cb93a386Sopenharmony_ci 157cb93a386Sopenharmony_ci# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158cb93a386Sopenharmony_cifunction splitJvmOpts() { 159cb93a386Sopenharmony_ci JVM_OPTS=("$@") 160cb93a386Sopenharmony_ci} 161cb93a386Sopenharmony_cieval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162cb93a386Sopenharmony_ciJVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163cb93a386Sopenharmony_ci 164cb93a386Sopenharmony_ciexec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165