1
- #! /usr/bin/env bash
1
+ #! /usr/bin/env sh
2
+ #
3
+ # Copyright 2015 the original author or authors.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
2
17
3
18
# #############################################################################
4
19
# #
5
20
# # Gradle start up script for UN*X
6
21
# #
7
22
# #############################################################################
8
23
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=" "
24
+ # Attempt to set APP_HOME
25
+ # Resolve links: $0 may be a link
26
+ PRG=" $0 "
27
+ # Need this for relative symlinks.
28
+ while [ -h " $PRG " ] ; do
29
+ ls=` ls -ld " $PRG " `
30
+ link=` expr " $ls " : ' .*-> \(.*\)$' `
31
+ if expr " $link " : ' /.*' > /dev/null; then
32
+ PRG=" $link "
33
+ else
34
+ PRG=` dirname " $PRG " ` " /$link "
35
+ fi
36
+ done
37
+ SAVED=" ` pwd` "
38
+ cd " ` dirname \" $PRG \" ` /" > /dev/null
39
+ APP_HOME=" ` pwd -P` "
40
+ cd " $SAVED " > /dev/null
11
41
12
42
APP_NAME=" Gradle"
13
43
APP_BASE_NAME=` basename " $0 " `
14
44
45
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
46
+ DEFAULT_JVM_OPTS=' "-Xmx64m" "-Xms64m"'
47
+
15
48
# Use the maximum available, or set MAX_FD != -1 to use that value.
16
49
MAX_FD=" maximum"
17
50
18
- warn ( ) {
51
+ warn () {
19
52
echo " $* "
20
53
}
21
54
22
- die ( ) {
55
+ die () {
23
56
echo
24
57
echo " $* "
25
58
echo
@@ -30,6 +63,7 @@ die ( ) {
30
63
cygwin=false
31
64
msys=false
32
65
darwin=false
66
+ nonstop=false
33
67
case " ` uname` " in
34
68
CYGWIN* )
35
69
cygwin=true
@@ -40,31 +74,11 @@ case "`uname`" in
40
74
MINGW* )
41
75
msys=true
42
76
;;
77
+ NONSTOP* )
78
+ nonstop=true
79
+ ;;
43
80
esac
44
81
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
-
68
82
CLASSPATH=$APP_HOME /gradle/wrapper/gradle-wrapper.jar
69
83
70
84
# Determine the Java command to use to start the JVM.
@@ -90,7 +104,7 @@ location of your Java installation."
90
104
fi
91
105
92
106
# Increase the maximum file descriptors if we can.
93
- if [ " $cygwin " = " false" -a " $darwin " = " false" ] ; then
107
+ if [ " $cygwin " = " false" -a " $darwin " = " false" -a " $nonstop " = " false " ] ; then
94
108
MAX_FD_LIMIT=` ulimit -H -n`
95
109
if [ $? -eq 0 ] ; then
96
110
if [ " $MAX_FD " = " maximum" -o " $MAX_FD " = " max" ] ; then
114
128
if $cygwin ; then
115
129
APP_HOME=` cygpath --path --mixed " $APP_HOME " `
116
130
CLASSPATH=` cygpath --path --mixed " $CLASSPATH " `
131
+ JAVACMD=` cygpath --unix " $JAVACMD " `
117
132
118
133
# We build the pattern for arguments to be converted via cygpath
119
134
ROOTDIRSRAW=` find -L / -maxdepth 1 -mindepth 1 -type d 2> /dev/null`
@@ -154,11 +169,17 @@ if $cygwin ; then
154
169
esac
155
170
fi
156
171
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=(" $@ " )
172
+ # Escape application args
173
+ save () {
174
+ for i do printf %s\\ n " $i " | sed " s/'/'\\\\ ''/g;1s/^/'/;\$ s/\$ /' \\\\ /" ; done
175
+ echo " "
160
176
}
161
- eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162
- JVM_OPTS[${# JVM_OPTS[*]} ]=" -Dorg.gradle.appname=$APP_BASE_NAME "
177
+ APP_ARGS=$( save " $@ " )
178
+ # Collect all arguments for the java command, following the shell quoting and substitution rules
179
+ eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS " \" -Dorg.gradle.appname=$APP_BASE_NAME \" " -classpath " \" $CLASSPATH \" " org.gradle.wrapper.GradleWrapperMain " $APP_ARGS "
180
+ # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
181
+ if [ " $( uname) " = " Darwin" ] && [ " $HOME " = " $PWD " ]; then
182
+ cd " $( dirname " $0 " ) "
183
+ fi
163
184
164
- exec " $JAVACMD " " ${JVM_OPTS[@]} " -classpath " $CLASSPATH " org.gradle.wrapper.GradleWrapperMain " $ @"
185
+ exec " $JAVACMD " " $@ "
0 commit comments