simple_mtglife

annotate android/gradlew @ 0:6321cfa2ad62

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