Skip to content

Commit 523a1b8

Browse files
committed
Reduce the length of the arguments in scaladoc.bat
1 parent f2829c3 commit 523a1b8

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

dist/bin/scaladoc.bat

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if defined JAVA_OPTS ( set _JAVA_OPTS=%JAVA_OPTS%
3131
set "_JAVACMD=!_JAVACMD:%%=%%%%!"
3232

3333
call "%_JAVACMD%" %_JAVA_OPTS% %_JAVA_DEBUG% %_JAVA_ARGS% ^
34-
-classpath "%_CLASS_PATH%" ^
34+
-classpath "@%_CLASS_PATH_FILE%" ^
3535
-Dscala.usejavacp=true ^
3636
dotty.tools.scaladoc.Main %_SCALA_ARGS% %_RESIDUAL_ARGS%
3737
if not %ERRORLEVEL%==0 (
@@ -79,9 +79,8 @@ if "%__ARG%"=="--" (
7979
) else if "%__ARG:~0,2%"=="-D" ( call :addJava "%__ARG%"
8080
) else if "%__ARG:~0,2%"=="-J" ( call :addJava "%__ARG:~2%"
8181
) else (
82-
if defined _IN_SCRIPTING_ARGS ( call :addScripting "%__ARG%"
83-
) else ( call :addResidual "%__ARG%"
84-
)
82+
if defined _IN_SCRIPTING_ARGS ( call :addScripting "%__ARG%")
83+
else ( call :addResidual "%__ARG%" )
8584
)
8685
shift
8786
goto args_loop
@@ -103,25 +102,33 @@ goto :eof
103102
set _RESIDUAL_ARGS=%_RESIDUAL_ARGS% %~1
104103
goto :eof
105104

106-
@rem output parameter: _CLASS_PATH
105+
@rem output parameter: _CLASS_PATH_FILE.
106+
@rem It contains the path th the absolute classpaths
107107
:classpathArgs
108-
set "_ETC_DIR=%_PROG_HOME%\etc"
109-
@rem keep list in sync with bash script `bin\scaladoc` !
110-
call :loadClasspathFromFile
108+
109+
set _ETC_DIR="%_PROG_HOME%\etc"
110+
set _TMP_DIR="%_PROG_HOME%\tmp"
111+
set _INPUT_CLASSPATH_FILE="%_ETC_DIR%\scaladoc.classpath"
112+
set _OUTPUT_CLASSPATH_FILE="%_TMP_DIR%\scaladoc.classpath"
113+
114+
@rem Check if the _TMP_DIR exists. If not, create it (first time we run the command)
115+
if not exist "%TMP_DIR%" ( mkdir "%TMP_DIR%" )
116+
117+
@rem If the file doesn't exist, create it (first time we run the command)
118+
if not exist "%_OUTPUT_CLASSPATH_FILE%" ( call :loadClasspathFromFile )
119+
set _CLASS_PATH_FILE="%_OUTPUT_CLASSPATH_FILE%"
111120
goto :eof
112121

113-
@REM concatentate every line in "%_ETC_DIR%\scaladoc.classpath" with _PSEP
122+
@REM concatentate every line in _INPUT_CLASSPATH_FILE and dump it in the with _PSEP
114123
:loadClasspathFromFile
115124
set _CLASS_PATH=
116-
if exist "%_ETC_DIR%\scaladoc.classpath" (
117-
for /f "usebackq delims=" %%i in ("%_ETC_DIR%\scaladoc.classpath") do (
118-
set "_LIB=%_PROG_HOME%\maven2\%%i"
125+
if exist "%_INPUT_CLASSPATH_FILE%" (
126+
for /f "usebackq delims=" %%i in "%_INPUT_CLASSPATH_FILE%" do (
127+
set _LIB="%_PROG_HOME%\maven2\%%i"
128+
@rem Adapt the paths from Unix style to MS-DOS style
119129
set "_LIB=!_LIB:/=\!"
120-
if not defined _CLASS_PATH (
121-
set "_CLASS_PATH=!_LIB!"
122-
) else (
123-
set "_CLASS_PATH=!_CLASS_PATH!%_PSEP%!_LIB!"
124-
)
130+
@rem Append the processed line to the output file, ensuring a new line
131+
echo !_LIB! >> "%_OUTPUT_CLASSPATH_FILE%"
125132
)
126133
)
127134
goto :eof

0 commit comments

Comments
 (0)