Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 42 additions & 28 deletions buildSrc/src/main/resources/unixStartScript.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -64,13 +66,13 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/${gitRef}/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#<% /*
# ... and if you're reading this, this IS the template just mentioned.
#
# This template is processed by
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/java/org/gradle/api/internal/plugins/UnixStartScriptGenerator.java
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/java/org/gradle/api/internal/plugins/UnixStartScriptGenerator.java
#
# Gradle is a meta-build system used by the project that you're building
# or installing. It's like autoconf but for projects that are written in
Expand All @@ -97,7 +99,7 @@
# (Template Engines) for details.
#
# (An example invocation of this template is from
# https://github.com/gradle/gradle/blob/HEAD/subprojects/build-init/src/main/java/org/gradle/api/tasks/wrapper/Wrapper.java
# https://github.com/gradle/gradle/blob/HEAD/platforms/software/build-init/src/main/java/org/gradle/api/tasks/wrapper/Wrapper.java
# within the Gradle project, which builds "gradlew".)
# */ %>
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -125,19 +127,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=\${0##*/}
APP_HOME=\$( cd "\${APP_HOME:-./}${appHomeRelativePath}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
DEFAULT_JVM_OPTS=${defaultJvmOpts}

# Customization for deephaven-core to reference a compiler directives file
# There is no easy way for users to override these options
DEFAULT_JVM_OPTS="\${DEFAULT_JVM_OPTS} -XX:+UnlockDiagnosticVMOptions -XX:CompilerDirectivesFile=\"\${APP_HOME}/etc/dh-compiler-directives.txt\""

# Customization for deephaven-core to include vm options file by default
# If users explicitly set JAVA_OPTS, they will be opting out of dh-default.vmoptions
DH_DEFAULT_VMOPTIONS="-XX:VMOptionsFile=\"\${APP_HOME}/etc/dh-default.vmoptions\""
JAVA_OPTS="\${JAVA_OPTS:-\${DH_DEFAULT_VMOPTIONS}}"
# Discard cd standard output in case \$CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=\$( cd -P "\${APP_HOME:-./}${appHomeRelativePath}" > /dev/null && printf '%s\\n' "\$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -167,8 +158,9 @@ esac

# Deephaven edit.
# Prepend EXTRA_CLASSPATH and colon if EXTRA_CLASSPATH is non-empty.
<% if ( classpath ) {%>\
CLASSPATH=\${EXTRA_CLASSPATH:+\$EXTRA_CLASSPATH:}$classpath

<% } %>\
<% if ( mainClassName.startsWith('--module ') ) { %>
MODULE_PATH=$modulePath
<% } %>
Expand All @@ -189,26 +181,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "\$cygwin" && ! "\$darwin" && ! "\$nonstop" ; then
case \$MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=\$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case \$MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "\$MAX_FD" ||
warn "Could not set maximum file descriptor limit to \$MAX_FD"
esac
Expand Down Expand Up @@ -253,19 +248,38 @@ if "\$cygwin" || "\$msys" ; then
done
fi

# Collect all arguments for the java command;
# * \$DEFAULT_JVM_OPTS, \$JAVA_OPTS, and \$${optsEnvironmentVar} can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
<% /*
# The DEFAULT_JVM_OPTS variable is intentionally defined here to allow using cygwin-processed APP_HOME.
# So far the only way to inject APP_HOME reference into DEFAULT_JVM_OPTS is to post-process the start script; the declaration is a good anchor to do that.
*/ %>
# Add default JVM options here. You can also use JAVA_OPTS and ${optsEnvironmentVar} to pass JVM options to this script.
DEFAULT_JVM_OPTS=${defaultJvmOpts}

# Customization for deephaven-core to reference a compiler directives file
# There is no easy way for users to override these options
DEFAULT_JVM_OPTS="\${DEFAULT_JVM_OPTS} -XX:+UnlockDiagnosticVMOptions -XX:CompilerDirectivesFile=\"\${APP_HOME}/etc/dh-compiler-directives.txt\""

# Customization for deephaven-core to include vm options file by default
# If users explicitly set JAVA_OPTS, they will be opting out of dh-default.vmoptions
DH_DEFAULT_VMOPTIONS="-XX:VMOptionsFile=\"\${APP_HOME}/etc/dh-default.vmoptions\""
JAVA_OPTS="\${JAVA_OPTS:-\${DH_DEFAULT_VMOPTIONS}}"

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect \${Hostname} to be expanded, as it is an environment variable and will be
# treated as '\${Hostname}' itself on the command line.

set -- \\
<% if ( appNameSystemProperty ) {
%> "-D${appNameSystemProperty}=\$APP_BASE_NAME" \\
<% } %> -classpath "\$CLASSPATH" \\
<% } %>\
<% if ( classpath ) {%>\
-classpath "\$CLASSPATH" \\
<% } %>\
<% if ( mainClassName.startsWith('--module ') ) {
%> --module-path "\$MODULE_PATH" \\
<% } %> ${mainClassName} \\
<% } %> ${mainClassName ?: entryPointArgs} \\
"\$@"

# Stop when "xargs" is not available.
Expand Down
Loading