gradlew 5.2 KB

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