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