Merge pull request #6514 from eed3si9n/wip/sbtn-download

Implement sbtn downloading
This commit is contained in:
eugene yokota 2021-05-23 17:48:03 -04:00 committed by GitHub
commit fdcff13804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 62 additions and 6 deletions

View File

@ -42,7 +42,7 @@ jobs:
JVM_OPTS: -Xms800M -Xmx2G -Xss6M -XX:ReservedCodeCacheSize=128M -server -Dsbt.io.virtual=false -Dfile.encoding=UTF-8
SCALA_212: 2.12.13
SCALA_213: 2.13.3
UTIL_TESTS: utilCache/test;utilControl/test;utilInterface/test;utilLogging/test;utilPosition/test;utilRelation/test;utilScripted/test;utilTracking/test
UTIL_TESTS: "utilCache/test utilControl/test utilInterface/test utilLogging/test utilPosition/test utilRelation/test utilScripted/test utilTracking/test"
SBT_LOCAL: false
TEST_SBT_VER: 1.5.0
SBT_ETC_FILE: $HOME/etc/sbt/sbtopts
@ -90,7 +90,23 @@ jobs:
rm -rf "$HOME/.sbt/scripted/" || true
case ${{ matrix.jobtype }} in
1)
./sbt -v "mimaReportBinaryIssues ; javafmtCheck ; Test / javafmtCheck; scalafmtCheckAll ; scalafmtSbtCheck; serverTestProj/scalafmtCheckAll; headerCheck ;test:headerCheck ;whitesourceOnPush ;test:compile; publishLocal; test; serverTestProj/test; doc; $UTIL_TESTS; ++$SCALA_213; $UTIL_TESTS"
./sbt -v --client mimaReportBinaryIssues
./sbt -v --client javafmtCheck
./sbt -v --client "Test/javafmtCheck"
./sbt -v --client scalafmtCheckAll
./sbt -v --client scalafmtSbtCheck
./sbt -v --client serverTestProj/scalafmtCheckAll
./sbt -v --client headerCheck
./sbt -v --client "Test/headerCheck"
./sbt -v --client whitesourceOnPush
./sbt -v --client "Test/compile"
./sbt -v --client publishLocal
./sbt -v --client test
./sbt -v --client "serverTestProj/test"
./sbt -v --client doc
./sbt -v --client "all $UTIL_TESTS"
./sbt -v --client ++$SCALA_213
./sbt -v --client "all $UTIL_TESTS"
;;
2)
./sbt -v "scripted actions/* apiinfo/* compiler-project/* ivy-deps-management/* reporter/* tests/* watch/* classloader-cache/* package/*"
@ -112,7 +128,7 @@ jobs:
cd ../
sbt -Dsbtlm.path=$HOME/work/sbt/sbt/librarymanagement -Dsbtzinc.path=$HOME/work/sbt/sbt/zinc -Dsbt.build.version=$BUILD_VERSION -Dsbt.build.fatal=false "+lowerUtils/publishLocal; {librarymanagement}/publishLocal; {zinc}/publishLocal; upperModules/publishLocal"
rm -r $(find $HOME/.sbt/boot -name "*-SNAPSHOT") || true
sbt -v -Dsbt.version=$BUILD_VERSION "++$SCALA_213; $UTIL_TESTS; ++$SCALA_212; $UTIL_TESTS; scripted actions/* source-dependencies/*1of3 dependency-management/*1of4 java/*"
sbt -v -Dsbt.version=$BUILD_VERSION "++$SCALA_213; all $UTIL_TESTS; ++$SCALA_212; all $UTIL_TESTS; scripted actions/* source-dependencies/*1of3 dependency-management/*1of4 java/*"
;;
7)
# test launcher script

View File

@ -118,6 +118,7 @@ val root = (project in file(".")).
// TODO - GPG Trust validation.
file
},
// update sbt.sh at root
sbtnVersion := "1.4.7",
sbtnJarsBaseUrl := "https://github.com/sbt/sbtn-dist/releases/download",
sbtnJarsMappings := {

45
sbt
View File

@ -22,6 +22,7 @@ declare sbt_debug=
declare build_props_sbt_version=
declare use_sbtn=
declare sbtn_command="$SBTN_CMD"
declare sbtn_version="1.4.7"
### ------------------------------- ###
### Helper methods for BASH scripts ###
@ -154,6 +155,42 @@ acquire_sbt_jar () {
fi
}
acquire_sbtn () {
local sbtn_v="$1"
local user_home && user_home=$(findProperty user.home)
local p="${user_home:-$HOME}/.cache/sbt/boot/sbtn/$sbtn_v"
local target="$p/sbtn"
local archive_target=
local url=
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
archive_target="$p/sbtn-x86_64-pc-linux-${sbtn_v}.tar.gz"
url="https://github.com/sbt/sbtn-dist/releases/download/v${sbtn_v}/sbtn-x86_64-pc-linux-${sbtn_v}.tar.gz"
elif [[ "$OSTYPE" == "darwin"* ]]; then
archive_target="$p/sbtn-x86_64-apple-darwin-${sbtn_v}.tar.gz"
url="https://github.com/sbt/sbtn-dist/releases/download/v${sbtn_v}/sbtn-x86_64-apple-darwin-${sbtn_v}.tar.gz"
elif [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
target="$p/sbtn.exe"
archive_target="$p/sbtn-x86_64-pc-win32-${sbtn_v}.zip"
url="https://github.com/sbt/sbtn-dist/releases/download/v${sbtn_v}/sbtn-x86_64-pc-win32-${sbtn_v}.zip"
else
echoerr "sbtn is not supported on $OSTYPE"
exit 2
fi
if [[ -f "$target" ]]; then
sbtn_command="$target"
else
echoerr "downloading sbtn ${sbtn_v}"
download_url "$url" "$archive_target"
if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then
tar zxf "$archive_target" --directory "$p"
else
unzip "$archive_target" -d "$p"
fi
sbtn_command="$target"
fi
}
# execRunner should be called only once to give up control to java
execRunner () {
# print the arguments one to a line, quoting any containing spaces
@ -661,7 +698,7 @@ isRunNativeClient() {
sbtBinaryV_1=$(echo "$sbtV" | sed 's/^\([0-9]*\)\.\([0-9]*\).*$/\1/')
sbtBinaryV_2=$(echo "$sbtV" | sed 's/^\([0-9]*\)\.\([0-9]*\).*$/\2/')
if (( $sbtBinaryV_1 >= 2 )) || ( (( $sbtBinaryV_1 >= 1 )) && (( $sbtBinaryV_2 >= 4 )) ); then
if [[ "$use_sbtn" == "1" ]] && [[ "$sbtn_command" != "" ]]; then
if [[ "$use_sbtn" == "1" ]]; then
echo "true"
else
echo "false"
@ -673,6 +710,10 @@ isRunNativeClient() {
runNativeClient() {
vlog "[debug] running native client"
detectNativeClient
[[ -f "$sbtn_command" ]] || acquire_sbtn "$sbtn_version" || {
exit 1
}
for i in "${!original_args[@]}"; do
if [[ "${original_args[i]}" = "--client" ]]; then
unset 'original_args[i]'
@ -702,8 +743,6 @@ original_args=("$@")
[[ -f "$build_props_file" ]] && loadPropFile "$build_props_file"
detectNativeClient
java_args=($JAVA_OPTS)
sbt_options0=(${SBT_OPTS:-$default_sbt_opts})
if [[ "$SBT_NATIVE_CLIENT" == "true" ]]; then