srctree

gradlew
0f95cb03  Robin Linden #!/bin/sh 30ce15dd  Robin Lindén f5a8a46d  Robin Linden # b366530d  Robin Linden # Copyright © 2015-2021 the original authors. f5a8a46d  Robin Linden # f5a8a46d  Robin Linden # Licensed under the Apache License, Version 2.0 (the "License"); f5a8a46d  Robin Linden # you may not use this file except in compliance with the License. f5a8a46d  Robin Linden # You may obtain a copy of the License at f5a8a46d  Robin Linden # f5a8a46d  Robin Linden # https://www.apache.org/licenses/LICENSE-2.0 f5a8a46d  Robin Linden # f5a8a46d  Robin Linden # Unless required by applicable law or agreed to in writing, software f5a8a46d  Robin Linden # distributed under the License is distributed on an "AS IS" BASIS, f5a8a46d  Robin Linden # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. f5a8a46d  Robin Linden # See the License for the specific language governing permissions and f5a8a46d  Robin Linden # limitations under the License. f5a8a46d  Robin Linden # 57eb4bc6  Robin Linden # SPDX-License-Identifier: Apache-2.0 57eb4bc6  Robin Linden # f5a8a46d  Robin Linden 30ce15dd  Robin Lindén ############################################################################## 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # Gradle start up script for POSIX generated by Gradle. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # Important for running: 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 0f95cb03  Robin Linden # noncompliant, but you have some other compliant shell such as ksh or 0f95cb03  Robin Linden # bash, then to run this script, type that shell name before the whole 0f95cb03  Robin Linden # command line, like: 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # ksh Gradle 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # Busybox and similar reduced shells will NOT work, because this script 0f95cb03  Robin Linden # requires all of these POSIX shell features: 0f95cb03  Robin Linden # * functions; b366530d  Robin Linden # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», b366530d  Robin Linden # «${var#prefix}», «${var%suffix}», and «$( cmd )»; b366530d  Robin Linden # * compound commands having a testable exit status, especially «case»; b366530d  Robin Linden # * various built-in commands including «command», «set», and «ulimit». 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # Important for patching: 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # (2) This script targets any POSIX shell, so it avoids extensions provided 0f95cb03  Robin Linden # by Bash, Ksh, etc; in particular arrays are avoided. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # The "traditional" practice of packing multiple parameters into a 0f95cb03  Robin Linden # space-separated string is a well documented source of bugs and security 0f95cb03  Robin Linden # problems, so this is (mostly) avoided, by progressively accumulating 0f95cb03  Robin Linden # options in "$@", and eventually passing that to Java. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 0f95cb03  Robin Linden # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 0f95cb03  Robin Linden # see the in-line comments for details. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # There are tweaks for specific operating systems such as AIX, CygWin, 0f95cb03  Robin Linden # Darwin, MinGW, and NonStop. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # (3) This script is generated from the Groovy template a3cc2a20  Robin Linden # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 0f95cb03  Robin Linden # within the Gradle project. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # You can find Gradle at https://github.com/gradle/gradle/. 0f95cb03  Robin Linden # 30ce15dd  Robin Lindén ############################################################################## 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén # Attempt to set APP_HOME 0f95cb03  Robin Linden 30ce15dd  Robin Lindén # Resolve links: $0 may be a link 0f95cb03  Robin Linden app_path=$0 0f95cb03  Robin Linden 0f95cb03  Robin Linden # Need this for daisy-chained symlinks. 0f95cb03  Robin Linden while 0f95cb03  Robin Linden APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 0f95cb03  Robin Linden [ -h "$app_path" ] 0f95cb03  Robin Linden do 0f95cb03  Robin Linden ls=$( ls -ld "$app_path" ) 0f95cb03  Robin Linden link=${ls#*' -> '} 0f95cb03  Robin Linden case $link in #( 0f95cb03  Robin Linden /*) app_path=$link ;; #( 0f95cb03  Robin Linden *) app_path=$APP_HOME$link ;; 0f95cb03  Robin Linden esac 30ce15dd  Robin Lindén done 0f95cb03  Robin Linden f5217541  Robin Linden # This is normally unused f5217541  Robin Linden # shellcheck disable=SC2034 0f95cb03  Robin Linden APP_BASE_NAME=${0##*/} 19d98e3a  Robin Linden # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 57eb4bc6  Robin Linden APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s 57eb4bc6  Robin Linden ' "$PWD" ) || exit 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén # Use the maximum available, or set MAX_FD != -1 to use that value. 0f95cb03  Robin Linden MAX_FD=maximum 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén warn () { 30ce15dd  Robin Lindén echo "$*" 0f95cb03  Robin Linden } >&2 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén die () { 30ce15dd  Robin Lindén echo 30ce15dd  Robin Lindén echo "$*" 30ce15dd  Robin Lindén echo 30ce15dd  Robin Lindén exit 1 0f95cb03  Robin Linden } >&2 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén # OS specific support (must be 'true' or 'false'). 30ce15dd  Robin Lindén cygwin=false 30ce15dd  Robin Lindén msys=false 30ce15dd  Robin Lindén darwin=false 30ce15dd  Robin Lindén nonstop=false 0f95cb03  Robin Linden case "$( uname )" in #( 0f95cb03  Robin Linden CYGWIN* ) cygwin=true ;; #( 0f95cb03  Robin Linden Darwin* ) darwin=true ;; #( 0f95cb03  Robin Linden MSYS* | MINGW* ) msys=true ;; #( 0f95cb03  Robin Linden NONSTOP* ) nonstop=true ;; 30ce15dd  Robin Lindén esac 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 30ce15dd  Robin Lindén 569c466e  Robin Linden 30ce15dd  Robin Lindén # Determine the Java command to use to start the JVM. 30ce15dd  Robin Lindén if [ -n "$JAVA_HOME" ] ; then 30ce15dd  Robin Lindén if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 30ce15dd  Robin Lindén # IBM's JDK on AIX uses strange locations for the executables 0f95cb03  Robin Linden JAVACMD=$JAVA_HOME/jre/sh/java 30ce15dd  Robin Lindén else 0f95cb03  Robin Linden JAVACMD=$JAVA_HOME/bin/java 30ce15dd  Robin Lindén fi 30ce15dd  Robin Lindén if [ ! -x "$JAVACMD" ] ; then 30ce15dd  Robin Lindén die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén Please set the JAVA_HOME variable in your environment to match the 30ce15dd  Robin Lindén location of your Java installation." 30ce15dd  Robin Lindén fi 30ce15dd  Robin Lindén else 0f95cb03  Robin Linden JAVACMD=java 19d98e3a  Robin Linden if ! command -v java >/dev/null 2>&1 19d98e3a  Robin Linden then 19d98e3a  Robin Linden die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén Please set the JAVA_HOME variable in your environment to match the 30ce15dd  Robin Lindén location of your Java installation." 19d98e3a  Robin Linden fi 30ce15dd  Robin Lindén fi 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén # Increase the maximum file descriptors if we can. 0f95cb03  Robin Linden if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 0f95cb03  Robin Linden case $MAX_FD in #( 0f95cb03  Robin Linden max*) f5217541  Robin Linden # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 76bf3154  Robin Linden # shellcheck disable=SC2039,SC3045 0f95cb03  Robin Linden MAX_FD=$( ulimit -H -n ) || 0f95cb03  Robin Linden warn "Could not query maximum file descriptor limit" 0f95cb03  Robin Linden esac 0f95cb03  Robin Linden case $MAX_FD in #( 0f95cb03  Robin Linden '' | soft) :;; #( 0f95cb03  Robin Linden *) f5217541  Robin Linden # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 76bf3154  Robin Linden # shellcheck disable=SC2039,SC3045 0f95cb03  Robin Linden ulimit -n "$MAX_FD" || 0f95cb03  Robin Linden warn "Could not set maximum file descriptor limit to $MAX_FD" 0f95cb03  Robin Linden esac 30ce15dd  Robin Lindén fi 30ce15dd  Robin Lindén 0f95cb03  Robin Linden # Collect all arguments for the java command, stacking in reverse order: 0f95cb03  Robin Linden # * args from the command line 0f95cb03  Robin Linden # * the main class name 0f95cb03  Robin Linden # * -classpath 0f95cb03  Robin Linden # * -D...appname settings 0f95cb03  Robin Linden # * --module-path (only if needed) 0f95cb03  Robin Linden # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 30ce15dd  Robin Lindén f5a8a46d  Robin Linden # For Cygwin or MSYS, switch paths to Windows format before running java 0f95cb03  Robin Linden if "$cygwin" || "$msys" ; then 0f95cb03  Robin Linden APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 0f95cb03  Robin Linden CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 0f95cb03  Robin Linden 0f95cb03  Robin Linden JAVACMD=$( cygpath --unix "$JAVACMD" ) 0f95cb03  Robin Linden 30ce15dd  Robin Lindén # Now convert the arguments - kludge to limit ourselves to /bin/sh 0f95cb03  Robin Linden for arg do 0f95cb03  Robin Linden if 0f95cb03  Robin Linden case $arg in #( 0f95cb03  Robin Linden -*) false ;; # don't mess with options #( 0f95cb03  Robin Linden /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 0f95cb03  Robin Linden [ -e "$t" ] ;; #( 0f95cb03  Robin Linden *) false ;; 0f95cb03  Robin Linden esac 0f95cb03  Robin Linden then 0f95cb03  Robin Linden arg=$( cygpath --path --ignore --mixed "$arg" ) 30ce15dd  Robin Lindén fi 0f95cb03  Robin Linden # Roll the args list around exactly as many times as the number of 0f95cb03  Robin Linden # args, so each arg winds up back in the position where it started, but 0f95cb03  Robin Linden # possibly modified. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # NB: a `for` loop captures its iteration list before it begins, so 0f95cb03  Robin Linden # changing the positional parameters here affects neither the number of 0f95cb03  Robin Linden # iterations, nor the values presented in `arg`. 0f95cb03  Robin Linden shift # remove old arg 0f95cb03  Robin Linden set -- "$@" "$arg" # push replacement arg 30ce15dd  Robin Lindén done 30ce15dd  Robin Lindén fi 30ce15dd  Robin Lindén 19d98e3a  Robin Linden 19d98e3a  Robin Linden # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 19d98e3a  Robin Linden DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 19d98e3a  Robin Linden 76bf3154  Robin Linden # Collect all arguments for the java command: 76bf3154  Robin Linden # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 76bf3154  Robin Linden # and any embedded shellness will be escaped. 76bf3154  Robin Linden # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 76bf3154  Robin Linden # treated as '${Hostname}' itself on the command line. 0f95cb03  Robin Linden 0f95cb03  Robin Linden set -- \ 0f95cb03  Robin Linden "-Dorg.gradle.appname=$APP_BASE_NAME" \ 0f95cb03  Robin Linden -classpath "$CLASSPATH" \ 0f95cb03  Robin Linden org.gradle.wrapper.GradleWrapperMain \ 0f95cb03  Robin Linden "$@" 0f95cb03  Robin Linden f57f24bf  Robin Linden # Stop when "xargs" is not available. f57f24bf  Robin Linden if ! command -v xargs >/dev/null 2>&1 f57f24bf  Robin Linden then f57f24bf  Robin Linden die "xargs is not available" f57f24bf  Robin Linden fi f57f24bf  Robin Linden 0f95cb03  Robin Linden # Use "xargs" to parse quoted args. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # In Bash we could simply go: 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # readarray ARGS < <( xargs -n1 <<<"$var" ) && 0f95cb03  Robin Linden # set -- "${ARGS[@]}" "$@" 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # but POSIX shell has neither arrays nor command substitution, so instead we 0f95cb03  Robin Linden # post-process each arg (as a line of input to sed) to backslash-escape any 0f95cb03  Robin Linden # character that might be a shell metacharacter, then use eval to reverse 0f95cb03  Robin Linden # that process (while maintaining the separation between arguments), and wrap 0f95cb03  Robin Linden # the whole thing up as a single "set" statement. 0f95cb03  Robin Linden # 0f95cb03  Robin Linden # This will of course break if any of these variables contains a newline or 0f95cb03  Robin Linden # an unmatched quote. 0f95cb03  Robin Linden # 30ce15dd  Robin Lindén 0f95cb03  Robin Linden eval "set -- $( 0f95cb03  Robin Linden printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 0f95cb03  Robin Linden xargs -n1 | 0f95cb03  Robin Linden sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 0f95cb03  Robin Linden tr '\n' ' ' 0f95cb03  Robin Linden )" '"$@"' 30ce15dd  Robin Lindén 30ce15dd  Robin Lindén exec "$JAVACMD" "$@"