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