Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 142 lines (127 sloc) 5.085 kb
4f679a17 » hd
2010-01-18 Added wrapper. Some cleaning up. Fixed one bug with bundlor.
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 -Xmx512"
11 # JAVA_OPTS="$JAVA_OPTS -Xmx512"
12
13 GRADLE_APP_NAME=Gradle
14
15 warn ( ) {
16 echo "${PROGNAME}: $*"
17 }
18
19 die ( ) {
20 warn "$*"
21 exit 1
22 }
23
24
25 # OS specific support (must be 'true' or 'false').
26 cygwin=false
27 msys=false
28 darwin=false
29 case "`uname`" in
30 CYGWIN* )
31 cygwin=true
32 ;;
33 Darwin* )
34 darwin=true
35 ;;
36 MINGW* )
37 msys=true
38 ;;
39 esac
40
41 # Attempt to set JAVA_HOME if it's not already set.
42 if [ -z "$JAVA_HOME" ] ; then
43 if $darwin ; then
44 [ -z "$JAVA_HOME" -a -d "/Library/Java/Home" ] && export JAVA_HOME="/Library/Java/Home"
45 [ -z "$JAVA_HOME" -a -d "/System/Library/Frameworks/JavaVM.framework/Home" ] && export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Home"
46 else
47 javaExecutable="`which javac`"
48 [ -z "$javaExecutable" -o "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ] && die "JAVA_HOME not set and cannot find javac to deduce location, please set JAVA_HOME."
49 # readlink(1) is not available as standard on Solaris 10.
50 readLink=`which readlink`
51 [ `expr "$readLink" : '\([^ ]*\)'` = "no" ] && die "JAVA_HOME not set and readlink not available, please set JAVA_HOME."
52 javaExecutable="`readlink -f \"$javaExecutable\"`"
53 javaHome="`dirname \"$javaExecutable\"`"
54 javaHome=`expr "$javaHome" : '\(.*\)/bin'`
55 export JAVA_HOME="$javaHome"
56 fi
57 fi
58
59 # For Cygwin, ensure paths are in UNIX format before anything is touched.
60 if $cygwin ; then
61 [ -n "$JAVACMD" ] && JAVACMD=`cygpath --unix "$JAVACMD"`
62 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
63 fi
64
65 STARTER_MAIN_CLASS=org.gradle.wrapper.GradleWrapperMain
66 CLASSPATH=`dirname "$0"`/gradle/wrapper/gradle-wrapper.jar
67 WRAPPER_PROPERTIES=`dirname "$0"`/gradle/wrapper/gradle-wrapper.properties
68 # Determine the Java command to use to start the JVM.
69 if [ -z "$JAVACMD" ] ; then
70 if [ -n "$JAVA_HOME" ] ; then
71 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 # IBM's JDK on AIX uses strange locations for the executables
73 JAVACMD="$JAVA_HOME/jre/sh/java"
74 else
75 JAVACMD="$JAVA_HOME/bin/java"
76 fi
77 else
78 JAVACMD="java"
79 fi
80 fi
81 if [ ! -x "$JAVACMD" ] ; then
82 die "JAVA_HOME is not defined correctly, can not execute: $JAVACMD"
83 fi
84 if [ -z "$JAVA_HOME" ] ; then
85 warn "JAVA_HOME environment variable is not set"
86 fi
87
88 # For Darwin, add GRADLE_APP_NAME to the JAVA_OPTS as -Xdock:name
89 if $darwin; then
90 JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GRADLE_APP_NAME"
91 # we may also want to set -Xdock:image
92 fi
93
94 # For Cygwin, switch paths to Windows format before running java
95 if $cygwin ; then
96 JAVA_HOME=`cygpath --path --mixed "$JAVA_HOME"`
97 CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
98
99 # We build the pattern for arguments to be converted via cygpath
100 ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
101 SEP=""
102 for dir in $ROOTDIRSRAW ; do
103 ROOTDIRS="$ROOTDIRS$SEP$dir"
104 SEP="|"
105 done
106 OURCYGPATTERN="(^($ROOTDIRS))"
107 # Add a user-defined pattern to the cygpath arguments
108 if [ "$GRADLE_CYGPATTERN" != "" ] ; then
109 OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
110 fi
111 # Now convert the arguments - kludge to limit ourselves to /bin/sh
112 i=0
113 for arg in "$@" ; do
114 CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
115 CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
116
117 if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
118 eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
119 else
120 eval `echo args$i`="\"$arg\""
121 fi
122 i=$((i+1))
123 done
124 case $i in
125 (0) set -- ;;
126 (1) set -- "$args0" ;;
127 (2) set -- "$args0" "$args1" ;;
128 (3) set -- "$args0" "$args1" "$args2" ;;
129 (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
130 (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
131 (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
132 (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
133 (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
134 (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
135 esac
136 fi
137
138 "$JAVACMD" $JAVA_OPTS $GRADLE_OPTS \
139 -classpath "$CLASSPATH" \
140 -Dorg.gradle.wrapper.properties="$WRAPPER_PROPERTIES" \
141 $STARTER_MAIN_CLASS \
142 "$@"
Something went wrong with that request. Please try again.