gradlew 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #!/usr/bin/env sh
  2. ##############################################################################
  3. ##
  4. ## Gradle start up script for UN*X
  5. ##
  6. ##############################################################################
  7. # Attempt to set APP_HOME
  8. # Resolve links: $0 may be a link
  9. PRG="$0"
  10. # Need this for relative symlinks.
  11. while [ -h "$PRG" ] ; do
  12. ls=`ls -ld "$PRG"`
  13. link=`expr "$ls" : '.*-> \(.*\)$'`
  14. if expr "$link" : '/.*' > /dev/null; then
  15. PRG="$link"
  16. else
  17. PRG=`dirname "$PRG"`"/$link"
  18. fi
  19. done
  20. SAVED="`pwd`"
  21. cd "`dirname \"$PRG\"`/" >/dev/null
  22. APP_HOME="`pwd -P`"
  23. cd "$SAVED" >/dev/null
  24. APP_NAME="Gradle"
  25. APP_BASE_NAME=`basename "$0"`
  26. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  27. DEFAULT_JVM_OPTS=""
  28. # Use the maximum available, or set MAX_FD != -1 to use that value.
  29. MAX_FD="maximum"
  30. warn () {
  31. echo "$*"
  32. }
  33. die () {
  34. echo
  35. echo "$*"
  36. echo
  37. exit 1
  38. }
  39. # OS specific support (must be 'true' or 'false').
  40. cygwin=false
  41. msys=false
  42. darwin=false
  43. nonstop=false
  44. case "`uname`" in
  45. CYGWIN* )
  46. cygwin=true
  47. ;;
  48. Darwin* )
  49. darwin=true
  50. ;;
  51. MINGW* )
  52. msys=true
  53. ;;
  54. NONSTOP* )
  55. nonstop=true
  56. ;;
  57. esac
  58. CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
  59. # Determine the Java command to use to start the JVM.
  60. if [ -n "$JAVA_HOME" ] ; then
  61. if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  62. # IBM's JDK on AIX uses strange locations for the executables
  63. JAVACMD="$JAVA_HOME/jre/sh/java"
  64. else
  65. JAVACMD="$JAVA_HOME/bin/java"
  66. fi
  67. if [ ! -x "$JAVACMD" ] ; then
  68. die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the location of your Java installation."
  69. fi
  70. else
  71. JAVACMD="java"
  72. which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  73. Please set the JAVA_HOME variable in your environment to match the
  74. location of your Java installation."
  75. fi
  76. # Increase the maximum file descriptors if we can.
  77. if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
  78. MAX_FD_LIMIT=`ulimit -H -n`
  79. if [ $? -eq 0 ] ; then
  80. if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
  81. MAX_FD="$MAX_FD_LIMIT"
  82. fi
  83. ulimit -n $MAX_FD
  84. if [ $? -ne 0 ] ; then
  85. warn "Could not set maximum file descriptor limit: $MAX_FD"
  86. fi
  87. else
  88. warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
  89. fi
  90. fi
  91. # For Darwin, add options to specify how the application appears in the dock
  92. if $darwin; then
  93. GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
  94. fi
  95. # For Cygwin, switch paths to Windows format before running java
  96. if $cygwin ; then
  97. APP_HOME=`cygpath --path --mixed "$APP_HOME"`
  98. CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
  99. JAVACMD=`cygpath --unix "$JAVACMD"`
  100. # We build the pattern for arguments to be converted via cygpath
  101. ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
  102. SEP=""
  103. for dir in $ROOTDIRSRAW ; do
  104. ROOTDIRS="$ROOTDIRS$SEP$dir"
  105. SEP="|"
  106. done
  107. OURCYGPATTERN="(^($ROOTDIRS))"
  108. # Add a user-defined pattern to the cygpath arguments
  109. if [ "$GRADLE_CYGPATTERN" != "" ] ; then
  110. OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
  111. fi
  112. # Now convert the arguments - kludge to limit ourselves to /bin/sh
  113. i=0
  114. for arg in "$@" ; do
  115. CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
  116. CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
  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. # Escape application args
  138. save () {
  139. for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
  140. echo " "
  141. }
  142. APP_ARGS=$(save "$@")
  143. # Collect all arguments for the java command, following the shell quoting and substitution rules
  144. eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
  145. # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
  146. if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
  147. cd "$(dirname "$0")"
  148. fi
  149. exec "$JAVACMD" "$@"