Skip to content
This repository has been archived by the owner on Apr 25, 2021. It is now read-only.

--verbose mode for Windows #291

Merged
merged 2 commits into from Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions citest/test.bat
Expand Up @@ -13,10 +13,10 @@ SET JAVA_HOME=C:\jdk11
SET PATH=C:\jdk11\bin;%PATH%
SET SBT_OPTS=-Xmx4g -Dfile.encoding=UTF8

"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about
"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true about

"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" about 1> output.txt 2> err.txt
"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true about 1> output.txt 2> err.txt

"freshly-baked\sbt\bin\sbt" "-Dsbt.no.format=true" check
"freshly-baked\sbt\bin\sbt" -Dsbt.no.format=true check

ENDLOCAL
46 changes: 46 additions & 0 deletions src/universal/bin/sbt.bat
Expand Up @@ -12,6 +12,7 @@
@echo off
set SBT_HOME=%~dp0
set SBT_ARGS=
set SBT_VERBOSE=

set DEFAULT_JAVA_OPTS=-Dfile.encoding=UTF-8

Expand Down Expand Up @@ -64,12 +65,26 @@ set INIT_SBT_VERSION=_TO_BE_REPLACED
:args_loop
if "%~1" == "" goto args_end

set g=%1
if "%~1" == "-jvm-debug" set JVM_DEBUG=true
if "%~1" == "--jvm-debug" set JVM_DEBUG=true

if "%~1" == "-java-home" set SET_JAVA_HOME=true
if "%~1" == "--java-home" set SET_JAVA_HOME=true

if "%~1" == "-v" (
set SBT_VERBOSE=true
goto args_next
)
if "%~1" == "-verbose" (
set SBT_VERBOSE=true
goto args_next
)
if "%~1" == "--verbose" (
set SBT_VERBOSE=true
goto args_next
)

if "%JVM_DEBUG%" == "true" (
set /a JVM_DEBUG_PORT=5005 2>nul >nul
) else if "!JVM_DEBUG!" == "true" (
Expand All @@ -80,6 +95,19 @@ if "%JVM_DEBUG%" == "true" (
) else if /I "%~1" == "new" (
set sbt_new=true
set SBT_ARGS=!SBT_ARGS! %1
) else if /I "%g:~0,2%" == "-D" (
rem special handling for -D since '=' gets parsed away
if x%g:^==% == x%g% (
if not "%~2" == "" (
set SBT_ARGS=!SBT_ARGS! "%~1=%~2"
shift
) else (
echo "%~1" is missing a value
goto error
)
) else (
set SBT_ARGS=!SBT_ARGS! %1
)
) else (
set SBT_ARGS=!SBT_ARGS! %1
)
Expand All @@ -102,6 +130,7 @@ if "%SET_JAVA_HOME%" == "true" (
)
)

:args_next
shift
goto args_loop
:args_end
Expand Down Expand Up @@ -149,10 +178,27 @@ if ERRORLEVEL 1 goto error
goto end

:run
if "%SBT_VERBOSE%" == "true" (
echo # Executing command line:
echo "%_JAVACMD%"
if not "%_JAVA_OPTS%" == "" ( call :echolist %_JAVA_OPTS% )
if not "%SBT_OPTS%" == "" ( call :echolist %SBT_OPTS% )
echo -cp "%SBT_HOME%sbt-launch.jar"
echo xsbt.boot.Boot
if not "%*" == "" ( call :echolist %* )
echo.
)

"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %*
goto :eof

:echolist
for /F "tokens=1*" %%g in ("%*") do (
echo %%g
if not x%%h == x call :echolist %%h
)
exit /B 0

:process
rem Parses x out of 1.x; for example 8 out of java version 1.8.0_xx
rem Otherwise, parses the major version; 9 out of java version 9-ea
Expand Down