kitaev@213: #!/bin/bash kitaev@213: kitaev@213: ############################################################################## kitaev@213: ## ## kitaev@213: ## Gradle wrapper script for UN*X ## kitaev@213: ## ## kitaev@213: ############################################################################## kitaev@213: kitaev@213: # Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together. kitaev@213: # GRADLE_OPTS="$GRADLE_OPTS -Xmx512m" kitaev@213: # JAVA_OPTS="$JAVA_OPTS -Xmx512m" kitaev@213: kitaev@213: GRADLE_APP_NAME=Gradle kitaev@213: kitaev@213: # Use the maximum available, or set MAX_FD != -1 to use that value. kitaev@213: MAX_FD="maximum" kitaev@213: kitaev@213: warn ( ) { kitaev@213: echo "$*" kitaev@213: } kitaev@213: kitaev@213: die ( ) { kitaev@213: echo kitaev@213: echo "$*" kitaev@213: echo kitaev@213: exit 1 kitaev@213: } kitaev@213: kitaev@213: # OS specific support (must be 'true' or 'false'). kitaev@213: cygwin=false kitaev@213: msys=false kitaev@213: darwin=false kitaev@213: case "`uname`" in kitaev@213: CYGWIN* ) kitaev@213: cygwin=true kitaev@213: ;; kitaev@213: Darwin* ) kitaev@213: darwin=true kitaev@213: ;; kitaev@213: MINGW* ) kitaev@213: msys=true kitaev@213: ;; kitaev@213: esac kitaev@213: kitaev@213: # Attempt to set JAVA_HOME if it's not already set. kitaev@213: if [ -z "$JAVA_HOME" ] ; then kitaev@213: if $darwin ; then kitaev@213: [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home" kitaev@213: [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" kitaev@213: else kitaev@213: javaExecutable="`which javac`" kitaev@213: [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME." kitaev@213: # readlink(1) is not available as standard on Solaris 10. kitaev@213: readLink=`which readlink` kitaev@213: [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME." kitaev@213: javaExecutable="`readlink -f \"$javaExecutable\"`" kitaev@213: javaHome="`dirname \"$javaExecutable\"`" kitaev@213: javaHome=`expr "$javaHome" : '\(.*\)/bin'` kitaev@213: export JAVA_HOME="$javaHome" kitaev@213: fi kitaev@213: fi kitaev@213: kitaev@213: # For Cygwin, ensure paths are in UNIX format before anything is touched. kitaev@213: if $cygwin ; then kitaev@213: [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"` kitaev@213: [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` kitaev@213: fi kitaev@213: kitaev@213: STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain kitaev@213: CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar kitaev@213: WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties kitaev@213: # Determine the Java command to use to start the JVM. kitaev@213: if [ -z "$JAVACMD" ] ; then kitaev@213: if [ -n "$JAVA_HOME" ] ; then kitaev@213: if [ -x "$JAVA_HOME/jre/sh/java" ] ; then kitaev@213: # IBM's JDK on AIX uses strange locations for the executables kitaev@213: JAVACMD="$JAVA_HOME/jre/sh/java" kitaev@213: else kitaev@213: JAVACMD="$JAVA_HOME/bin/java" kitaev@213: fi kitaev@213: else kitaev@213: JAVACMD="java" kitaev@213: fi kitaev@213: fi kitaev@213: if [ ! -x "$JAVACMD" ] ; then kitaev@213: die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME kitaev@213: kitaev@213: Please set the JAVA_HOME variable in your environment to match the kitaev@213: location of your Java installation." kitaev@213: fi kitaev@213: if [ -z "$JAVA_HOME" ] ; then kitaev@213: warn "JAVA_HOME environment variable is not set" kitaev@213: fi kitaev@213: kitaev@213: # Increase the maximum file descriptors if we can. kitaev@213: if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then kitaev@213: MAX_FD_LIMIT=`ulimit -H -n` kitaev@213: if [ $? -eq 0 ] ; then kitaev@213: if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then kitaev@213: MAX_FD="$MAX_FD_LIMIT" kitaev@213: fi kitaev@213: ulimit -n $MAX_FD kitaev@213: if [ $? -ne 0 ] ; then kitaev@213: warn "Could not set maximum file descriptor limit: $MAX_FD" kitaev@213: fi kitaev@213: else kitaev@213: warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT" kitaev@213: fi kitaev@213: fi kitaev@213: kitaev@213: # For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name kitaev@213: if $darwin; then kitaev@213: JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME" kitaev@213: # we may also want to set -Xdock:image kitaev@213: fi kitaev@213: kitaev@213: # For Cygwin, switch paths to Windows format before running java kitaev@213: if $cygwin ; then kitaev@213: JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"` kitaev@213: CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` kitaev@213: kitaev@213: # We build the pattern for arguments to be converted via cygpath kitaev@213: ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` kitaev@213: SEP="" kitaev@213: for dir in $ROOTDIRSRAW ; do kitaev@213: ROOTDIRS="$ROOTDIRS$SEP$dir" kitaev@213: SEP="|" kitaev@213: done kitaev@213: OURCYGPATTERN="(^($ROOTDIRS))" kitaev@213: # Add a user-defined pattern to the cygpath arguments kitaev@213: if [ "$GRADLE_CYGPATTERN" != "" ] ; then kitaev@213: OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" kitaev@213: fi kitaev@213: # Now convert the arguments - kludge to limit ourselves to /bin/sh kitaev@213: i=0 kitaev@213: for arg in "$@" ; do kitaev@213: CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` kitaev@213: CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option kitaev@213: kitaev@213: if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition kitaev@213: eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` kitaev@213: else kitaev@213: eval `echo args$i`="\"$arg\"" kitaev@213: fi kitaev@213: i=$((i+1)) kitaev@213: done kitaev@213: case $i in kitaev@213: (0) set -- ;; kitaev@213: (1) set -- "$args0" ;; kitaev@213: (2) set -- "$args0" "$args1" ;; kitaev@213: (3) set -- "$args0" "$args1" "$args2" ;; kitaev@213: (4) set -- "$args0" "$args1" "$args2" "$args3" ;; kitaev@213: (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; kitaev@213: (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; kitaev@213: (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; kitaev@213: (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; kitaev@213: (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; kitaev@213: esac kitaev@213: fi kitaev@213: kitaev@213: GRADLE_APP_BASE_NAME=`basename "$0"` kitaev@213: kitaev@213: exec "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \ kitaev@213: -classpath "$CLASSPATH" \ kitaev@213: -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \ kitaev@213: -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \ kitaev@213: $STARTER_MAIN_CLASS \ kitaev@213: "$@"