Skip to content

Commit e9494ef

Browse files
authored
Benchmarks: Adopt gradle wrapper (#14)
1 parent 413e3d6 commit e9494ef

File tree

4 files changed

+120
-102
lines changed

4 files changed

+120
-102
lines changed

benchmarks/.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
120
.gradle
221
build
322
bin/
23+
24+
# Ignore Gradle wrapper jar file
25+
gradle/wrapper/gradle-wrapper.jar
26+
gradle/wrapper/gradle-wrapper-*.sha256
27+
28+
# Log files
29+
*.log
30+
logs/
31+
32+
# binary files
33+
*.class
34+
*.jar
35+
*.zip
36+
*.tar.gz
37+
*.tgz
38+
39+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
40+
hs_err_pid*
41+
42+
# macOS
43+
*.DS_Store
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
19+
# Downloads the gradle-wrapper.jar if necessary and verifies its integrity.
20+
# Included from /.gradlew
21+
22+
# Extract the Gradle version from gradle-wrapper.properties.
23+
GRADLE_DIST_VERSION="$(grep distributionUrl= "$APP_HOME/gradle/wrapper/gradle-wrapper.properties" | sed 's/^.*gradle-\([0-9.]*\)-[a-z]*.zip$/\1/')"
24+
GRADLE_WRAPPER_SHA256="$APP_HOME/gradle/wrapper/gradle-wrapper-${GRADLE_DIST_VERSION}.jar.sha256"
25+
GRADLE_WRAPPER_JAR="$APP_HOME/gradle/wrapper/gradle-wrapper.jar"
26+
if [ -x "$(command -v sha256sum)" ] ; then
27+
SHASUM="sha256sum"
28+
else
29+
if [ -x "$(command -v shasum)" ] ; then
30+
SHASUM="shasum -a 256"
31+
else
32+
echo "Neither sha256sum nor shasum are available, install either." > /dev/stderr
33+
exit 1
34+
fi
35+
fi
36+
if [ ! -e "${GRADLE_WRAPPER_SHA256}" ]; then
37+
# Delete the wrapper jar, if the checksum file does not exist.
38+
rm -f "${GRADLE_WRAPPER_JAR}"
39+
fi
40+
if [ -e "${GRADLE_WRAPPER_JAR}" ]; then
41+
# Verify the wrapper jar, if it exists, delete wrapper jar and checksum file, if the checksums
42+
# do not match.
43+
JAR_CHECKSUM="$(${SHASUM} "${GRADLE_WRAPPER_JAR}" | cut -d\ -f1)"
44+
EXPECTED="$(cat "${GRADLE_WRAPPER_SHA256}")"
45+
if [ "${JAR_CHECKSUM}" != "${EXPECTED}" ]; then
46+
rm -f "${GRADLE_WRAPPER_JAR}" "${GRADLE_WRAPPER_SHA256}"
47+
fi
48+
fi
49+
if [ ! -e "${GRADLE_WRAPPER_SHA256}" ]; then
50+
curl --location --output "${GRADLE_WRAPPER_SHA256}" https://services.gradle.org/distributions/gradle-${GRADLE_DIST_VERSION}-wrapper.jar.sha256 || exit 1
51+
fi
52+
if [ ! -e "${GRADLE_WRAPPER_JAR}" ]; then
53+
# The Gradle version extracted from the `distributionUrl` property does not contain ".0" patch
54+
# versions. Need to append a ".0" in that case to download the wrapper jar.
55+
GRADLE_VERSION="$(echo "$GRADLE_DIST_VERSION" | sed 's/^\([0-9]*[.][0-9]*\)$/\1.0/')"
56+
curl --location --output "${GRADLE_WRAPPER_JAR}" https://raw.githubusercontent.com/gradle/gradle/v${GRADLE_VERSION}/gradle/wrapper/gradle-wrapper.jar || exit 1
57+
JAR_CHECKSUM="$(${SHASUM} "${GRADLE_WRAPPER_JAR}" | cut -d\ -f1)"
58+
EXPECTED="$(cat "${GRADLE_WRAPPER_SHA256}")"
59+
if [ "${JAR_CHECKSUM}" != "${EXPECTED}" ]; then
60+
# If the (just downloaded) checksum and the downloaded wrapper jar do not match, something
61+
# really bad is going on.
62+
echo "Expected sha256 of the downloaded gradle-wrapper.jar does not match the downloaded sha256!" > /dev/stderr
63+
exit 1
64+
fi
65+
fi

benchmarks/gradlew

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,7 +85,10 @@ done
8385
# This is normally unused
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
88+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90+
91+
. ${APP_HOME}/gradle/gradlew-include.sh
8792

8893
# Use the maximum available, or set MAX_FD != -1 to use that value.
8994
MAX_FD=maximum
@@ -144,15 +149,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144149
case $MAX_FD in #(
145150
max*)
146151
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
152+
# shellcheck disable=SC2039,SC3045
148153
MAX_FD=$( ulimit -H -n ) ||
149154
warn "Could not query maximum file descriptor limit"
150155
esac
151156
case $MAX_FD in #(
152157
'' | soft) :;; #(
153158
*)
154159
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
160+
# shellcheck disable=SC2039,SC3045
156161
ulimit -n "$MAX_FD" ||
157162
warn "Could not set maximum file descriptor limit to $MAX_FD"
158163
esac
@@ -201,11 +206,11 @@ fi
201206
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
202207
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
203208

204-
# Collect all arguments for the java command;
205-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
206-
# shell script including quotes and variable substitutions, so put them in
207-
# double quotes to make sure that they get re-expanded; and
208-
# * put everything else in single quotes, so that it's not re-expanded.
209+
# Collect all arguments for the java command:
210+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
211+
# and any embedded shellness will be escaped.
212+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
213+
# treated as '${Hostname}' itself on the command line.
209214

210215
set -- \
211216
"-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -245,4 +250,4 @@ eval "set -- $(
245250
tr '\n' ' '
246251
)" '"$@"'
247252

248-
exec "$JAVACMD" "$@"
253+
exec "$JAVACMD" "$@"

benchmarks/gradlew.bat

Lines changed: 0 additions & 92 deletions
This file was deleted.

0 commit comments

Comments
 (0)