blob: 014f353c7d9ccaee59ea33f5eaae57544c51a274 [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
9# 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 -070010
11APP_NAME="Gradle"
12APP_BASE_NAME=`basename "$0"`
13
14# Use the maximum available, or set MAX_FD != -1 to use that value.
15MAX_FD="maximum"
16
17warn ( ) {
18 echo "$*"
19}
20
21die ( ) {
22 echo
23 echo "$*"
24 echo
25 exit 1
26}
27
28# OS specific support (must be 'true' or 'false').
29cygwin=false
30msys=false
31darwin=false
32case "`uname`" in
33 CYGWIN* )
34 cygwin=true
35 ;;
36 Darwin* )
37 darwin=true
38 ;;
39 MINGW* )
40 msys=true
41 ;;
42esac
43
Xavier Ducrohet0f3d9032014-03-18 17:25:21 -070044# Attempt to set APP_HOME
45# Resolve links: $0 may be a link
46PRG="$0"
47# Need this for relative symlinks.
48while [ -h "$PRG" ] ; do
49 ls=`ls -ld "$PRG"`
50 link=`expr "$ls" : '.*-> \(.*\)$'`
51 if expr "$link" : '/.*' > /dev/null; then
52 PRG="$link"
53 else
54 PRG=`dirname "$PRG"`"/$link"
55 fi
56done
57SAVED="`pwd`"
Yigit Boyarf77697d2016-08-16 10:55:36 -070058cd "`dirname \"$PRG\"`/" >/dev/null
Xavier Ducrohet0f3d9032014-03-18 17:25:21 -070059APP_HOME="`pwd -P`"
Yigit Boyarf77697d2016-08-16 10:55:36 -070060cd "$SAVED" >/dev/null
Xavier Ducrohet0f3d9032014-03-18 17:25:21 -070061
62CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
63
Alan Viveretted38b36c2017-02-01 16:45:31 -050064# Pick the correct fullsdk for this OS.
65if [ "$os" = "Darwin" ]; then
66 plat="darwin"
67else
68 plat="linux"
69fi
70DEFAULT_JVM_OPTS="-DLINT_API_DATABASE=$APP_HOME/../../prebuilts/fullsdk-$plat/platform-tools/api/api-versions.xml"
71
Xavier Ducrohet0f3d9032014-03-18 17:25:21 -070072# 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 "$@"