• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env sh
2
3#
4# Copyright 2016-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
5#
6
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
15PRG="$0"
16# Need this for relative symlinks.
17while [ -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
25done
26SAVED="`pwd`"
27cd "`dirname \"$PRG\"`/" >/dev/null
28APP_HOME="`pwd -P`"
29cd "$SAVED" >/dev/null
30
31APP_NAME="Gradle"
32APP_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.
35DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
36
37# Use the maximum available, or set MAX_FD != -1 to use that value.
38MAX_FD="maximum"
39
40warn () {
41    echo "$*"
42}
43
44die () {
45    echo
46    echo "$*"
47    echo
48    exit 1
49}
50
51# OS specific support (must be 'true' or 'false').
52cygwin=false
53msys=false
54darwin=false
55nonstop=false
56case "`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    ;;
69esac
70
71CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
72
73
74# Determine the Java command to use to start the JVM.
75if [ -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
85Please set the JAVA_HOME variable in your environment to match the
86location of your Java installation."
87    fi
88else
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
92Please set the JAVA_HOME variable in your environment to match the
93location of your Java installation."
94fi
95
96# Increase the maximum file descriptors if we can.
97if [ "$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
110fi
111
112# For Darwin, add options to specify how the application appears in the dock
113if $darwin; then
114    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
115fi
116
117# For Cygwin or MSYS, switch paths to Windows format before running java
118if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
119    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
120    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
121
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
147        i=`expr $i + 1`
148    done
149    case $i in
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" ;;
160    esac
161fi
162
163# Escape application args
164save () {
165    for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
166    echo " "
167}
168APP_ARGS=`save "$@"`
169
170# Collect all arguments for the java command, following the shell quoting and substitution rules
171eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
172
173exec "$JAVACMD" "$@"
174