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