commit
8674c153b7
74
build/sbt
74
build/sbt
@ -1,34 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# When creating new tests for Spark SQL Hive, the HADOOP_CLASSPATH must contain the hive jars so
|
||||
# that we can run Hive to generate the golden answer. This is not required for normal development
|
||||
# or testing.
|
||||
for i in $HIVE_HOME/lib/*
|
||||
do HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$i
|
||||
for i in "$HIVE_HOME"/lib/*
|
||||
do HADOOP_CLASSPATH="$HADOOP_CLASSPATH:$i"
|
||||
done
|
||||
export HADOOP_CLASSPATH
|
||||
|
||||
realpath () {
|
||||
(
|
||||
TARGET_FILE=$1
|
||||
TARGET_FILE="$1"
|
||||
|
||||
cd $(dirname $TARGET_FILE)
|
||||
TARGET_FILE=$(basename $TARGET_FILE)
|
||||
cd "$(dirname "$TARGET_FILE")"
|
||||
TARGET_FILE="$(basename "$TARGET_FILE")"
|
||||
|
||||
COUNT=0
|
||||
while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
|
||||
do
|
||||
TARGET_FILE=$(readlink $TARGET_FILE)
|
||||
cd $(dirname $TARGET_FILE)
|
||||
TARGET_FILE=$(basename $TARGET_FILE)
|
||||
TARGET_FILE="$(readlink "$TARGET_FILE")"
|
||||
cd $(dirname "$TARGET_FILE")
|
||||
TARGET_FILE="$(basename $TARGET_FILE)"
|
||||
COUNT=$(($COUNT + 1))
|
||||
done
|
||||
|
||||
echo $(pwd -P)/$TARGET_FILE
|
||||
echo "$(pwd -P)/"$TARGET_FILE""
|
||||
)
|
||||
}
|
||||
|
||||
. $(dirname $(realpath $0))/sbt-launch-lib.bash
|
||||
. "$(dirname "$(realpath "$0")")"/sbt-launch-lib.bash
|
||||
|
||||
|
||||
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
|
||||
@ -38,6 +55,7 @@ declare -r etc_sbt_opts_file="/etc/sbt/sbtopts"
|
||||
usage() {
|
||||
cat <<EOM
|
||||
Usage: $script_name [options]
|
||||
|
||||
-h | -help print this message
|
||||
-v | -verbose this runner is chattier
|
||||
-d | -debug set sbt log level to debug
|
||||
@ -51,13 +69,16 @@ Usage: $script_name [options]
|
||||
-no-global uses global caches, but does not use global ~/.sbt directory.
|
||||
-jvm-debug <port> Turn on JVM debugging, open at the given port.
|
||||
-batch Disable interactive mode
|
||||
|
||||
# sbt version (default: from project/build.properties if present, else latest release)
|
||||
-sbt-version <version> use the specified version of sbt
|
||||
-sbt-jar <path> use the specified jar as the sbt launcher
|
||||
-sbt-rc use an RC version of sbt
|
||||
-sbt-snapshot use a snapshot version of sbt
|
||||
|
||||
# java version (default: java from PATH, currently $(java -version 2>&1 | grep version))
|
||||
-java-home <path> alternate JAVA_HOME
|
||||
|
||||
# jvm options and output control
|
||||
JAVA_OPTS environment variable, if unset uses "$java_opts"
|
||||
SBT_OPTS environment variable, if unset uses "$default_sbt_opts"
|
||||
@ -67,8 +88,9 @@ Usage: $script_name [options]
|
||||
-Dkey=val pass -Dkey=val directly to the java runtime
|
||||
-J-X pass option -X directly to the java runtime
|
||||
(-J is stripped)
|
||||
-S-X add -X to sbt's scalacOptions (-J is stripped)
|
||||
-PmavenProfiles Enable a maven profile for the build.
|
||||
-S-X add -X to sbt's scalacOptions (-S is stripped)
|
||||
-PmavenProfiles Enable a maven profile for the build.
|
||||
|
||||
In the case of duplicated or conflicting options, the order above
|
||||
shows precedence: JAVA_OPTS lowest, command line options highest.
|
||||
EOM
|
||||
@ -103,4 +125,32 @@ loadConfigFile() {
|
||||
[[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@"
|
||||
[[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@"
|
||||
|
||||
exit_status=127
|
||||
saved_stty=""
|
||||
|
||||
restoreSttySettings() {
|
||||
stty $saved_stty
|
||||
saved_stty=""
|
||||
}
|
||||
|
||||
onExit() {
|
||||
if [[ "$saved_stty" != "" ]]; then
|
||||
restoreSttySettings
|
||||
fi
|
||||
exit $exit_status
|
||||
}
|
||||
|
||||
saveSttySettings() {
|
||||
saved_stty=$(stty -g 2>/dev/null)
|
||||
if [[ ! $? ]]; then
|
||||
saved_stty=""
|
||||
fi
|
||||
}
|
||||
|
||||
saveSttySettings
|
||||
trap onExit INT
|
||||
|
||||
run "$@"
|
||||
|
||||
exit_status=$?
|
||||
onExit
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
# TODO - Should we merge the main SBT script with this library?
|
||||
|
||||
if test -z "$HOME"; then
|
||||
declare -r script_dir="$(dirname $script_path)"
|
||||
declare -r script_dir="$(dirname "$script_path")"
|
||||
else
|
||||
declare -r script_dir="$HOME/.sbt"
|
||||
fi
|
||||
@ -37,29 +37,30 @@ dlog () {
|
||||
}
|
||||
|
||||
acquire_sbt_jar () {
|
||||
SBT_VERSION=`awk -F "=" '/sbt\\.version/ {print $2}' ./project/build.properties`
|
||||
URL1=http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/${SBT_VERSION}/sbt-launch.jar
|
||||
URL2=http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/${SBT_VERSION}/sbt-launch.jar
|
||||
SBT_VERSION=`awk -F "=" '/sbt\.version/ {print $2}' ./project/build.properties`
|
||||
URL1=https://dl.bintray.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/${SBT_VERSION}/sbt-launch.jar
|
||||
JAR=build/sbt-launch-${SBT_VERSION}.jar
|
||||
|
||||
sbt_jar=$JAR
|
||||
|
||||
if [[ ! -f "$sbt_jar" ]]; then
|
||||
# Download sbt launch jar if it hasn't been downloaded yet
|
||||
if [ ! -f ${JAR} ]; then
|
||||
if [ ! -f "${JAR}" ]; then
|
||||
# Download
|
||||
printf "Attempting to fetch sbt\n"
|
||||
JAR_DL=${JAR}.part
|
||||
if hash curl 2>/dev/null; then
|
||||
(curl --progress-bar ${URL1} > ${JAR_DL} || curl --progress-bar ${URL2} > ${JAR_DL}) && mv ${JAR_DL} ${JAR}
|
||||
elif hash wget 2>/dev/null; then
|
||||
(wget --progress=bar ${URL1} -O ${JAR_DL} || wget --progress=bar ${URL2} -O ${JAR_DL}) && mv ${JAR_DL} ${JAR}
|
||||
JAR_DL="${JAR}.part"
|
||||
if [ $(command -v curl) ]; then
|
||||
curl --fail --location --silent ${URL1} > "${JAR_DL}" &&\
|
||||
mv "${JAR_DL}" "${JAR}"
|
||||
elif [ $(command -v wget) ]; then
|
||||
wget --quiet ${URL1} -O "${JAR_DL}" &&\
|
||||
mv "${JAR_DL}" "${JAR}"
|
||||
else
|
||||
printf "You do not have curl or wget installed, please install sbt manually from http://www.scala-sbt.org/\n"
|
||||
exit -1
|
||||
fi
|
||||
fi
|
||||
if [ ! -f ${JAR} ]; then
|
||||
if [ ! -f "${JAR}" ]; then
|
||||
# We failed to download
|
||||
printf "Our attempt to download sbt locally to ${JAR} failed. Please install sbt manually from http://www.scala-sbt.org/\n"
|
||||
exit -1
|
||||
@ -81,7 +82,7 @@ execRunner () {
|
||||
echo ""
|
||||
}
|
||||
|
||||
exec "$@"
|
||||
"$@"
|
||||
}
|
||||
|
||||
addJava () {
|
||||
@ -104,7 +105,7 @@ addResidual () {
|
||||
residual_args=( "${residual_args[@]}" "$1" )
|
||||
}
|
||||
addDebugger () {
|
||||
addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"
|
||||
addJava "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=$1"
|
||||
}
|
||||
|
||||
# a ham-fisted attempt to move some memory settings in concert
|
||||
@ -124,7 +125,8 @@ require_arg () {
|
||||
local opt="$2"
|
||||
local arg="$3"
|
||||
if [[ -z "$arg" ]] || [[ "${arg:0:1}" == "-" ]]; then
|
||||
die "$opt requires <$type> argument"
|
||||
echo "$opt requires <$type> argument" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
@ -185,10 +187,3 @@ run() {
|
||||
"${sbt_commands[@]}" \
|
||||
"${residual_args[@]}"
|
||||
}
|
||||
|
||||
runAlternateBoot() {
|
||||
local bootpropsfile="$1"
|
||||
shift
|
||||
addJava "-Dsbt.boot.properties=$bootpropsfile"
|
||||
run $@
|
||||
}
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
// This file should only contain the version of sbt to use.
|
||||
sbt.version=0.13.6
|
||||
sbt.version=0.13.8
|
||||
|
||||
Loading…
Reference in New Issue
Block a user