Mercurial > hg4j
comparison gradlew @ 213:6ec4af642ba8 gradle
Project uses Gradle for build - actual changes
author | Alexander Kitaev <kitaev@gmail.com> |
---|---|
date | Tue, 10 May 2011 10:52:53 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
212:edb2e2829352 | 213:6ec4af642ba8 |
---|---|
1 #!/bin/bash | |
2 | |
3 ############################################################################## | |
4 ## ## | |
5 ## Gradle wrapper script for UN*X ## | |
6 ## ## | |
7 ############################################################################## | |
8 | |
9 # Uncomment those lines to set JVM options. GRADLE_OPTS and JAVA_OPTS can be used together. | |
10 # GRADLE_OPTS="$GRADLE_OPTS -Xmx512m" | |
11 # JAVA_OPTS="$JAVA_OPTS -Xmx512m" | |
12 | |
13 GRADLE_APP_NAME=Gradle | |
14 | |
15 # Use the maximum available, or set MAX_FD != -1 to use that value. | |
16 MAX_FD="maximum" | |
17 | |
18 warn ( ) { | |
19 echo "$*" | |
20 } | |
21 | |
22 die ( ) { | |
23 echo | |
24 echo "$*" | |
25 echo | |
26 exit 1 | |
27 } | |
28 | |
29 # OS specific support (must be 'true' or 'false'). | |
30 cygwin=false | |
31 msys=false | |
32 darwin=false | |
33 case "`uname`" in | |
34 CYGWIN* ) | |
35 cygwin=true | |
36 ;; | |
37 Darwin* ) | |
38 darwin=true | |
39 ;; | |
40 MINGW* ) | |
41 msys=true | |
42 ;; | |
43 esac | |
44 | |
45 # Attempt to set JAVA_HOME if it's not already set. | |
46 if [ -z "$JAVA_HOME" ] ; then | |
47 if $darwin ; then | |
48 [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home" | |
49 [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home" | |
50 else | |
51 javaExecutable="`which javac`" | |
52 [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME." | |
53 # readlink(1) is not available as standard on Solaris 10. | |
54 readLink=`which readlink` | |
55 [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME." | |
56 javaExecutable="`readlink -f \"$javaExecutable\"`" | |
57 javaHome="`dirname \"$javaExecutable\"`" | |
58 javaHome=`expr "$javaHome" : '\(.*\)/bin'` | |
59 export JAVA_HOME="$javaHome" | |
60 fi | |
61 fi | |
62 | |
63 # For Cygwin, ensure paths are in UNIX format before anything is touched. | |
64 if $cygwin ; then | |
65 [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"` | |
66 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` | |
67 fi | |
68 | |
69 STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain | |
70 CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar | |
71 WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties | |
72 # Determine the Java command to use to start the JVM. | |
73 if [ -z "$JAVACMD" ] ; then | |
74 if [ -n "$JAVA_HOME" ] ; then | |
75 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | |
76 # IBM's JDK on AIX uses strange locations for the executables | |
77 JAVACMD="$JAVA_HOME/jre/sh/java" | |
78 else | |
79 JAVACMD="$JAVA_HOME/bin/java" | |
80 fi | |
81 else | |
82 JAVACMD="java" | |
83 fi | |
84 fi | |
85 if [ ! -x "$JAVACMD" ] ; then | |
86 die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME | |
87 | |
88 Please set the JAVA_HOME variable in your environment to match the | |
89 location of your Java installation." | |
90 fi | |
91 if [ -z "$JAVA_HOME" ] ; then | |
92 warn "JAVA_HOME environment variable is not set" | |
93 fi | |
94 | |
95 # Increase the maximum file descriptors if we can. | |
96 if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then | |
97 MAX_FD_LIMIT=`ulimit -H -n` | |
98 if [ $? -eq 0 ] ; then | |
99 if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then | |
100 MAX_FD="$MAX_FD_LIMIT" | |
101 fi | |
102 ulimit -n $MAX_FD | |
103 if [ $? -ne 0 ] ; then | |
104 warn "Could not set maximum file descriptor limit: $MAX_FD" | |
105 fi | |
106 else | |
107 warn "Could not query businessSystem maximum file descriptor limit: $MAX_FD_LIMIT" | |
108 fi | |
109 fi | |
110 | |
111 # For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name | |
112 if $darwin; then | |
113 JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME" | |
114 # we may also want to set -Xdock:image | |
115 fi | |
116 | |
117 # For Cygwin, switch paths to Windows format before running java | |
118 if $cygwin ; then | |
119 JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"` | |
120 CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` | |
121 | |
122 # We build the pattern for arguments to be converted via cygpath | |
123 ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` | |
124 SEP="" | |
125 for dir in $ROOTDIRSRAW ; do | |
126 ROOTDIRS="$ROOTDIRS$SEP$dir" | |
127 SEP="|" | |
128 done | |
129 OURCYGPATTERN="(^($ROOTDIRS))" | |
130 # Add a user-defined pattern to the cygpath arguments | |
131 if [ "$GRADLE_CYGPATTERN" != "" ] ; then | |
132 OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" | |
133 fi | |
134 # Now convert the arguments - kludge to limit ourselves to /bin/sh | |
135 i=0 | |
136 for arg in "$@" ; do | |
137 CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` | |
138 CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option | |
139 | |
140 if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition | |
141 eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` | |
142 else | |
143 eval `echo args$i`="\"$arg\"" | |
144 fi | |
145 i=$((i+1)) | |
146 done | |
147 case $i in | |
148 (0) set -- ;; | |
149 (1) set -- "$args0" ;; | |
150 (2) set -- "$args0" "$args1" ;; | |
151 (3) set -- "$args0" "$args1" "$args2" ;; | |
152 (4) set -- "$args0" "$args1" "$args2" "$args3" ;; | |
153 (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; | |
154 (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; | |
155 (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; | |
156 (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; | |
157 (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; | |
158 esac | |
159 fi | |
160 | |
161 GRADLE_APP_BASE_NAME=`basename "$0"` | |
162 | |
163 exec "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \ | |
164 -classpath "$CLASSPATH" \ | |
165 -Dorg.gradle.appname="$GRADLE_APP_BASE_NAME" \ | |
166 -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \ | |
167 $STARTER_MAIN_CLASS \ | |
168 "$@" |