use delayed expansion

Fixes sbt/sbt#3804

Inside the if, it seems like bunch of variables were set to blank.
Using delayed expansion seems to fix this. This is confirmed by the newly added test.
This commit is contained in:
Eugene Yokota 2017-12-14 02:23:25 -05:00
parent 49d85750af
commit f9b9d082f6
2 changed files with 16 additions and 21 deletions

View File

@ -9,23 +9,19 @@ lazy val root = (project in file("."))
println(xs)
assert(xs(0) startsWith "Copying runtime jar.")
// echo of jar name
assert(xs(2) startsWith "[info] Loading project definition")
assert(xs(3) startsWith "[info] Loading settings from build.sbt")
assert(xs(4) startsWith "[info] Set current project to Hello")
assert(xs(5) startsWith "[info] This is sbt")
assert(xs(6) startsWith "[info] The current project")
assert(xs(7) startsWith "[info] The current project is built against Scala 2.12.4")
assert(xs(0) startsWith "[info] Loading project definition")
assert(xs(1) startsWith "[info] Loading settings from build.sbt")
assert(xs(2) startsWith "[info] Set current project to Hello")
assert(xs(3) startsWith "[info] This is sbt")
assert(xs(4) startsWith "[info] The current project")
assert(xs(5) startsWith "[info] The current project is built against Scala 2.12.4")
val ys = IO.readLines(file("err.txt")).toVector
println(ys)
assert(ys.size == 4)
assert(ys(0) startsWith "Error: Unable to access jarfile")
assert(ys(1) startsWith "The filename, directory name, or volume label syntax is incorrect.")
assert(ys(2) startsWith "Error: Unable to access jarfile")
assert(ys(3) startsWith "Java HotSpot(TM) 64-Bit Server VM warning")
assert(ys.size == 2)
assert(ys(0) startsWith "Java HotSpot(TM) 64-Bit Server VM warning")
assert(ys(1) startsWith "Java HotSpot(TM) 64-Bit Server VM warning")
}
)

View File

@ -131,16 +131,15 @@ exit /B 1
if /I "%JAVA_VERSION%" GEQ "9" (
set rtexport="%SBT_HOME%java9-rt-export.jar"
"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" --rt-ext-dir > "%TEMP%.\rtext.txt"
"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" --rt-ext-dir > "%TEMP%.\rtext.txt"
set /p java9_ext= < "%TEMP%.\rtext.txt"
set java9_rt=%java9_ext%\rt.jar
set java9_rt=!java9_ext!\rt.jar
if not exist "%java9_rt%" (
echo Copying runtime jar.
mkdir "%java9_ext%"
"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "%rtexport%" "%java9_rt%"
if not exist "!java9_rt!" (
mkdir "!java9_ext!"
"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -jar "!rtexport!" "!java9_rt!"
)
set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="%java9_ext%"
set _JAVA_OPTS=!_JAVA_OPTS! -Dscala.ext.dirs="!java9_ext!"
rem check to see if a GC has been set in the opts
echo !_JAVA_OPTS! | findstr /r "Use.*GC" >nul
@ -162,7 +161,7 @@ set PRELOAD_SBT_JAR="%UserProfile%\.sbt\preloaded\org.scala-sbt\sbt\%INIT_SBT_VE
if /I "%JAVA_VERSION%" GEQ "1.8" (
where robocopy >nul 2>nul
if %ERRORLEVEL% equ 0 (
echo %PRELOAD_SBT_JAR%
REM echo %PRELOAD_SBT_JAR%
if not exist %PRELOAD_SBT_JAR% (
if exist "%SBT_HOME%\..\lib\local-preloaded\" (
echo 'about to robocopy'