1- #! /usr/bin/env bash
1+ #! /usr/bin/env sh
2+
3+ #
4+ # Copyright 2015 the original author or authors.
5+ #
6+ # Licensed under the Apache License, Version 2.0 (the "License");
7+ # you may not use this file except in compliance with the License.
8+ # You may obtain a copy of the License at
9+ #
10+ # http://www.apache.org/licenses/LICENSE-2.0
11+ #
12+ # Unless required by applicable law or agreed to in writing, software
13+ # distributed under the License is distributed on an "AS IS" BASIS,
14+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+ # See the License for the specific language governing permissions and
16+ # limitations under the License.
17+ #
218
319# #############################################################################
420# #
521# # Gradle start up script for UN*X
622# #
723# #############################################################################
824
9- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10- DEFAULT_JVM_OPTS=" "
25+ # Attempt to set APP_HOME
26+ # Resolve links: $0 may be a link
27+ PRG=" $0 "
28+ # Need this for relative symlinks.
29+ while [ -h " $PRG " ] ; do
30+ ls=` ls -ld " $PRG " `
31+ link=` expr " $ls " : ' .*-> \(.*\)$' `
32+ if expr " $link " : ' /.*' > /dev/null; then
33+ PRG=" $link "
34+ else
35+ PRG=` dirname " $PRG " ` " /$link "
36+ fi
37+ done
38+ SAVED=" ` pwd` "
39+ cd " ` dirname \" $PRG \" ` /" > /dev/null
40+ APP_HOME=" ` pwd -P` "
41+ cd " $SAVED " > /dev/null
1142
1243APP_NAME=" Gradle"
1344APP_BASE_NAME=` basename " $0 " `
1445
46+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47+ DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
48+
1549# Use the maximum available, or set MAX_FD != -1 to use that value.
1650MAX_FD=" maximum"
1751
18- warn ( ) {
52+ warn () {
1953 echo " $* "
2054}
2155
22- die ( ) {
56+ die () {
2357 echo
2458 echo " $* "
2559 echo
@@ -30,6 +64,7 @@ die ( ) {
3064cygwin=false
3165msys=false
3266darwin=false
67+ nonstop=false
3368case " ` uname` " in
3469 CYGWIN* )
3570 cygwin=true
@@ -40,31 +75,11 @@ case "`uname`" in
4075 MINGW* )
4176 msys=true
4277 ;;
78+ NONSTOP* )
79+ nonstop=true
80+ ;;
4381esac
4482
45- # For Cygwin, ensure paths are in UNIX format before anything is touched.
46- if $cygwin ; then
47- [ -n " $JAVA_HOME " ] && JAVA_HOME=` cygpath --unix " $JAVA_HOME " `
48- fi
49-
50- # Attempt to set APP_HOME
51- # Resolve links: $0 may be a link
52- PRG=" $0 "
53- # Need this for relative symlinks.
54- while [ -h " $PRG " ] ; do
55- ls=` ls -ld " $PRG " `
56- link=` expr " $ls " : ' .*-> \(.*\)$' `
57- if expr " $link " : ' /.*' > /dev/null; then
58- PRG=" $link "
59- else
60- PRG=` dirname " $PRG " ` " /$link "
61- fi
62- done
63- SAVED=" ` pwd` "
64- cd " ` dirname \" $PRG \" ` /" >& -
65- APP_HOME=" ` pwd -P` "
66- cd " $SAVED " >& -
67-
6883CLASSPATH=$APP_HOME /gradle/wrapper/gradle-wrapper.jar
6984
7085# Determine the Java command to use to start the JVM.
@@ -90,7 +105,7 @@ location of your Java installation."
90105fi
91106
92107# Increase the maximum file descriptors if we can.
93- if [ " $cygwin " = " false" -a " $darwin " = " false" ] ; then
108+ if [ " $cygwin " = " false" -a " $darwin " = " false" -a " $nonstop " = " false " ] ; then
94109 MAX_FD_LIMIT=` ulimit -H -n`
95110 if [ $? -eq 0 ] ; then
96111 if [ " $MAX_FD " = " maximum" -o " $MAX_FD " = " max" ] ; then
114129if $cygwin ; then
115130 APP_HOME=` cygpath --path --mixed " $APP_HOME " `
116131 CLASSPATH=` cygpath --path --mixed " $CLASSPATH " `
132+ JAVACMD=` cygpath --unix " $JAVACMD " `
117133
118134 # We build the pattern for arguments to be converted via cygpath
119135 ROOTDIRSRAW=` find -L / -maxdepth 1 -mindepth 1 -type d 2> /dev/null`
@@ -154,11 +170,19 @@ if $cygwin ; then
154170 esac
155171fi
156172
157- # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158- function splitJvmOpts() {
159- JVM_OPTS=(" $@ " )
173+ # Escape application args
174+ save () {
175+ for i do printf %s\\ n " $i " | sed " s/'/'\\\\ ''/g;1s/^/'/;\$ s/\$ /' \\\\ /" ; done
176+ echo " "
160177}
161- eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162- JVM_OPTS[${# JVM_OPTS[*]} ]=" -Dorg.gradle.appname=$APP_BASE_NAME "
178+ APP_ARGS=$( save " $@ " )
179+
180+ # Collect all arguments for the java command, following the shell quoting and substitution rules
181+ eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS " \" -Dorg.gradle.appname=$APP_BASE_NAME \" " -classpath " \" $CLASSPATH \" " org.gradle.wrapper.GradleWrapperMain " $APP_ARGS "
182+
183+ # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184+ if [ " $( uname) " = " Darwin" ] && [ " $HOME " = " $PWD " ]; then
185+ cd " $( dirname " $0 " ) "
186+ fi
163187
164- exec " $JAVACMD " " ${JVM_OPTS[@]} " -classpath " $CLASSPATH " org.gradle.wrapper.GradleWrapperMain " $ @"
188+ exec " $JAVACMD " " $@ "
0 commit comments