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