From ef8011df0d4f6eaecbf7bfa651e001fb7853b29e Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 28 Apr 2017 02:26:49 +0900 Subject: [PATCH 1/5] fix: least java version check for syncing "preloaded" --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 1f72b990e..3625438d9 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -144,7 +144,7 @@ exit /B 0 :sync_preloaded set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VERSION%\jars\sbt.jar" -if /I "%JAVA_VERSION%" GEQ "8" ( +if /I "%JAVA_VERSION%" GEQ "1.8" ( where robocopy >nul 2>nul if %ERRORLEVEL% equ 0 ( echo %PRELOAD_SBT_JAR% From fb30f81f8961afefb69b97a7616e476a97637fed Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 28 Apr 2017 02:27:48 +0900 Subject: [PATCH 2/5] fix: recursive copying needs "/E" option --- src/universal/bin/sbt.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 3625438d9..bf447dc98 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -151,7 +151,7 @@ if /I "%JAVA_VERSION%" GEQ "1.8" ( if not exist %PRELOAD_SBT_JAR% ( if exist "%SBT_HOME%\..\lib\local-preloaded\" ( echo 'about to robocopy' - robocopy "%SBT_HOME%\..\lib\local-preloaded\" "%UserProfile%\.sbt\preloaded" + robocopy "%SBT_HOME%\..\lib\local-preloaded" "%UserProfile%\.sbt\preloaded" /E ) ) ) From ab3de739d722b1b9c8f38e3321f3d1e8692be332 Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 28 Apr 2017 02:28:16 +0900 Subject: [PATCH 3/5] detect $init_sbt_version --- src/universal/bin/sbt-launch-lib.bash | 4 ++++ src/universal/bin/sbt.bat | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 2264868a2..04824bf19 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -170,6 +170,10 @@ process_args () { } syncPreloaded() { + if [[ "$init_sbt_version" == "" ]]; then + # FIXME: better $init_sbt_version detection + init_sbt_version="$(ls -1 "$sbt_home/lib/local-preloaded/org.scala-sbt/sbt/")" + fi [[ -f "$HOME/.sbt/preloaded/org.scala-sbt/sbt/$init_sbt_version/jars/sbt.jar" ]] || { # lib/local-preloaded exists (This is optional) [[ -d "$sbt_home/lib/local-preloaded/" ]] && { diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index bf447dc98..85f5f0951 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -143,6 +143,12 @@ if /I "%JAVA_VERSION%" GEQ "9" ( exit /B 0 :sync_preloaded +if "%INIT_SBT_VERSION%"=="" ( + rem FIXME: better %INIT_SBT_VERSION% detection + FOR /F "tokens=* USEBACKQ" %%F IN (`dir /b "%SBT_HOME%\..\lib\local-preloaded\org.scala-sbt\sbt" /B`) DO ( + SET INIT_SBT_VERSION=%%F + ) +) set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VERSION%\jars\sbt.jar" if /I "%JAVA_VERSION%" GEQ "1.8" ( where robocopy >nul 2>nul From a602ed760eb1ad0e9af6eca176443411fc47ba1a Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 5 May 2017 00:29:52 +0900 Subject: [PATCH 4/5] Fix missing placeholder `INIT_SBT_VERSION' --- src/universal/bin/sbt.bat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 85f5f0951..884248abc 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -53,6 +53,8 @@ rem We use the value of the JAVA_OPTS environment variable if defined, rather th set _JAVA_OPTS=%JAVA_OPTS% if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% +set INIT_SBT_VERSION= + :args_loop if "%~1" == "" goto args_end From b66b0ff7f69fc916e13ca098eb879ad0f374223e Mon Sep 17 00:00:00 2001 From: tksk Date: Fri, 5 May 2017 15:45:20 +0900 Subject: [PATCH 5/5] Fix: multiple execution of universal:stage task produces duplicated version strings --- build.sbt | 6 ++++-- src/universal/bin/sbt-launch-lib.bash | 2 +- src/universal/bin/sbt.bat | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 09dbbfa9e..90b7f7921 100644 --- a/build.sbt +++ b/build.sbt @@ -155,9 +155,11 @@ val root = (project in file(".")). val old = (stage in Universal).value val sd = (stagingDirectory in Universal).value val x = IO.read(sd / "bin" / "sbt-launch-lib.bash") - IO.write(sd / "bin" / "sbt-launch-lib.bash", x.replaceAllLiterally("declare init_sbt_version=", s"declare init_sbt_version=$sbtVersionToRelease")) + IO.write(sd / "bin" / "sbt-launch-lib.bash", x.replaceAllLiterally( + "declare init_sbt_version=_to_be_replaced", s"declare init_sbt_version=$sbtVersionToRelease")) val y = IO.read(sd / "bin" / "sbt.bat") - IO.write(sd / "bin" / "sbt.bat", y.replaceAllLiterally("set INIT_SBT_VERSION=", s"set INIT_SBT_VERSION=$sbtVersionToRelease")) + IO.write(sd / "bin" / "sbt.bat", y.replaceAllLiterally( + "set INIT_SBT_VERSION=_TO_BE_REPLACED", s"set INIT_SBT_VERSION=$sbtVersionToRelease")) old }, diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 04824bf19..59d8af3d6 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -12,7 +12,7 @@ declare -a scalac_args declare -a sbt_commands declare java_cmd=java declare java_version -declare init_sbt_version= +declare init_sbt_version=_to_be_replaced declare SCRIPT=$0 while [ -h "$SCRIPT" ] ; do diff --git a/src/universal/bin/sbt.bat b/src/universal/bin/sbt.bat index 884248abc..6035dc357 100644 --- a/src/universal/bin/sbt.bat +++ b/src/universal/bin/sbt.bat @@ -53,7 +53,7 @@ rem We use the value of the JAVA_OPTS environment variable if defined, rather th set _JAVA_OPTS=%JAVA_OPTS% if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS% -set INIT_SBT_VERSION= +set INIT_SBT_VERSION=_TO_BE_REPLACED :args_loop if "%~1" == "" goto args_end