gradlew 5.4 KB

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