1
1
#! /usr/bin/env sh
2
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
- # https://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
- #
18
-
19
3
# #############################################################################
20
4
# #
21
5
# # Gradle start up script for UN*X
@@ -44,7 +28,7 @@ APP_NAME="Gradle"
44
28
APP_BASE_NAME=` basename " $0 " `
45
29
46
30
# 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" '
31
+ DEFAULT_JVM_OPTS=" "
48
32
49
33
# Use the maximum available, or set MAX_FD != -1 to use that value.
50
34
MAX_FD=" maximum"
@@ -120,13 +104,42 @@ if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
120
104
fi
121
105
fi
122
106
107
+ # #########################################################################################
108
+ # Extension to allow automatically downloading the gradle-wrapper.jar
109
+ # This allows using the maven wrapper in projects that prohibit checking in binary data.
110
+ # #########################################################################################
111
+ WRAPPER_JAR_PATH=" $APP_HOME /gradle/wrapper/gradle-wrapper.jar"
112
+ if [ ! -r " ${WRAPPER_JAR_PATH} " ]; then
113
+ jarUrl=" https://raw.githubusercontent.com/gradle/gradle/master/gradle/wrapper/gradle-wrapper.jar"
114
+ if command -v wget > /dev/null; then
115
+ wget -q " ${jarUrl} " -O " ${WRAPPER_JAR_PATH} "
116
+ elif command -v curl > /dev/null; then
117
+ curl -s -o " ${WRAPPER_JAR_PATH} " " $jarUrl "
118
+ else
119
+ javaClass=" $APP_HOME /gradle/wrapper/GradleWrapperDownloader.java"
120
+ if [ -e " $javaClass " ]; then
121
+ if [ ! -e " $APP_HOME /gradle/wrapper/GradleWrapperDownloader.class" ]; then
122
+ # Compiling the Java class
123
+ (" ${JAVACMD} c" " $javaClass " )
124
+ fi
125
+ if [ -e " $APP_HOME /gradle/wrapper/GradleWrapperDownloader.class" ]; then
126
+ (" $JAVACMD " -cp gradle/wrapper GradleWrapperDownloader " $APP_HOME " )
127
+ fi
128
+ fi
129
+ fi
130
+ fi
131
+ # #########################################################################################
132
+ # End of extension
133
+ # #########################################################################################
134
+
135
+
123
136
# For Darwin, add options to specify how the application appears in the dock
124
137
if $darwin ; then
125
138
GRADLE_OPTS=" $GRADLE_OPTS \" -Xdock:name=$APP_NAME \" \" -Xdock:icon=$APP_HOME /media/gradle.icns\" "
126
139
fi
127
140
128
- # For Cygwin or MSYS , switch paths to Windows format before running java
129
- if [ " $cygwin " = " true " -o " $msys " = " true " ] ; then
141
+ # For Cygwin, switch paths to Windows format before running java
142
+ if $cygwin ; then
130
143
APP_HOME=` cygpath --path --mixed " $APP_HOME " `
131
144
CLASSPATH=` cygpath --path --mixed " $CLASSPATH " `
132
145
JAVACMD=` cygpath --unix " $JAVACMD " `
@@ -154,19 +167,19 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
154
167
else
155
168
eval ` echo args$i ` =" \" $arg \" "
156
169
fi
157
- i=` expr $i + 1 `
170
+ i=$(( i + 1 ))
158
171
done
159
172
case $i in
160
- 0) set -- ;;
161
- 1) set -- " $args0 " ;;
162
- 2) set -- " $args0 " " $args1 " ;;
163
- 3) set -- " $args0 " " $args1 " " $args2 " ;;
164
- 4) set -- " $args0 " " $args1 " " $args2 " " $args3 " ;;
165
- 5) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " ;;
166
- 6) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " " $args5 " ;;
167
- 7) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " " $args5 " " $args6 " ;;
168
- 8) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " " $args5 " " $args6 " " $args7 " ;;
169
- 9) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " " $args5 " " $args6 " " $args7 " " $args8 " ;;
173
+ ( 0) set -- ;;
174
+ ( 1) set -- " $args0 " ;;
175
+ ( 2) set -- " $args0 " " $args1 " ;;
176
+ ( 3) set -- " $args0 " " $args1 " " $args2 " ;;
177
+ ( 4) set -- " $args0 " " $args1 " " $args2 " " $args3 " ;;
178
+ ( 5) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " ;;
179
+ ( 6) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " " $args5 " ;;
180
+ ( 7) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " " $args5 " " $args6 " ;;
181
+ ( 8) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " " $args5 " " $args6 " " $args7 " ;;
182
+ ( 9) set -- " $args0 " " $args1 " " $args2 " " $args3 " " $args4 " " $args5 " " $args6 " " $args7 " " $args8 " ;;
170
183
esac
171
184
fi
172
185
@@ -175,9 +188,14 @@ save () {
175
188
for i do printf %s\\ n " $i " | sed " s/'/'\\\\ ''/g;1s/^/'/;\$ s/\$ /' \\\\ /" ; done
176
189
echo " "
177
190
}
178
- APP_ARGS=` save " $@ " `
191
+ APP_ARGS=$( save " $@ " )
179
192
180
193
# Collect all arguments for the java command, following the shell quoting and substitution rules
181
194
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS " \" -Dorg.gradle.appname=$APP_BASE_NAME \" " -classpath " \" $CLASSPATH \" " org.gradle.wrapper.GradleWrapperMain " $APP_ARGS "
182
195
196
+ # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
197
+ if [ " $( uname) " = " Darwin" ] && [ " $HOME " = " $PWD " ]; then
198
+ cd " $( dirname " $0 " ) "
199
+ fi
200
+
183
201
exec " $JAVACMD " " $@ "
0 commit comments