Skip to content

Commit bf67032

Browse files
committed
read last line, split-off with-compiler classpath
1 parent c004c74 commit bf67032

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed

dist/bin/common

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,30 @@ load_classpath () {
1010
command="$1"
1111
psep_pattern="$2"
1212
__CLASS_PATH=""
13-
while IFS= read -r line; do
13+
while IFS= read -r line || [ -n "$line" ]; do
14+
# jna-5 only appropriate for some combinations
1415
if ! [[ ( -n ${conemu-} || -n ${msys-}) && "$line" == "*jna-5*" ]]; then
15-
# jna-5 only appropriate for some combinations
16-
__CLASS_PATH+="$PROG_HOME/maven2/$line$psep_pattern"
16+
if [ -n "$__CLASS_PATH" ]; then
17+
__CLASS_PATH+="$psep_pattern"
18+
fi
19+
__CLASS_PATH+="$PROG_HOME/maven2/$line"
1720
fi
1821
done < "$PROG_HOME/etc/$command.classpath"
1922
echo "$__CLASS_PATH"
2023
}
2124

2225
compilerJavaClasspathArgs () {
2326
toolchain="$(load_classpath "scala" "$PSEP")"
27+
toolchain_extra="$(load_classpath "with_compiler" "$PSEP")"
28+
29+
if [ -n "$toolchain_extra" ]; then
30+
toolchain+="$PSEP$toolchain_extra"
31+
fi
2432

2533
if [ -n "${jvm_cp_args-}" ]; then
2634
jvm_cp_args="$toolchain$jvm_cp_args"
2735
else
28-
jvm_cp_args="$toolchain$PSEP"
36+
jvm_cp_args="$toolchain"
2937
fi
3038
}
3139

dist/bin/scalac.bat

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,16 @@ goto :eof
8989
@rem output parameter: _JVM_CP_ARGS
9090
:compilerJavaClasspathArgs
9191

92-
call :loadClasspathFromFile
92+
set "CP_FILE=%_ETC_DIR%\scala.classpath"
93+
call :loadClasspathFromFile %CP_FILE%
94+
set "__TOOLCHAIN=%_CLASS_PATH_RESULT%"
9395

94-
set "__TOOLCHAIN=%_CLASS_PATH%"
96+
set "CP_FILE=%_ETC_DIR%\with_compiler.classpath"
97+
call :loadClasspathFromFile %CP_FILE%
98+
99+
if defined _CLASS_PATH_RESULT (
100+
set "__TOOLCHAIN=%__TOOLCHAIN%%_PSEP%%_CLASS_PATH_RESULT%"
101+
)
95102

96103
if defined _SCALA_CPATH (
97104
set "_JVM_CP_ARGS=%__TOOLCHAIN%%_SCALA_CPATH%"
@@ -100,17 +107,19 @@ if defined _SCALA_CPATH (
100107
)
101108
goto :eof
102109

103-
@REM concatentate every line in "%_ETC_DIR%\scala.classpath" with _PSEP
110+
@REM concatentate every line in "%_ARG_FILE%" with _PSEP
111+
@REM arg 1 - file to read
104112
:loadClasspathFromFile
105-
set _CLASS_PATH=
106-
if exist "%_ETC_DIR%\scala.classpath" (
107-
for /f "usebackq delims=" %%i in ("%_ETC_DIR%\scala.classpath") do (
113+
set _ARG_FILE=%1
114+
set _CLASS_PATH_RESULT=
115+
if exist "%_ARG_FILE%" (
116+
for /f "usebackq delims=" %%i in ("%_ARG_FILE%") do (
108117
set "_LIB=%_PROG_HOME%\maven2\%%i"
109118
set "_LIB=!_LIB:/=\!"
110-
if not defined _CLASS_PATH (
111-
set "_CLASS_PATH=!_LIB!"
119+
if not defined _CLASS_PATH_RESULT (
120+
set "_CLASS_PATH_RESULT=!_LIB!"
112121
) else (
113-
set "_CLASS_PATH=!_CLASS_PATH!%_PSEP%!_LIB!"
122+
set "_CLASS_PATH_RESULT=!_CLASS_PATH_RESULT!%_PSEP%!_LIB!"
114123
)
115124
)
116125
)

project/Build.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,9 @@ object Build {
21292129
packResourceDir += (republishRepo.value / "maven2" -> "maven2"),
21302130
packResourceDir += (republishRepo.value / "etc" -> "etc"),
21312131
republishCommandLibs +=
2132-
("scala" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core", "scala3-staging", "scala3-tasty-inspector")),
2132+
("scala" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core")),
2133+
republishCommandLibs +=
2134+
("with_compiler" -> List("scala3-staging", "scala3-tasty-inspector", "^!scala3-interfaces", "^!scala3-compiler", "^!scala3-library", "^!tasty-core")),
21332135
republishCommandLibs +=
21342136
("scaladoc" -> List("scala3-interfaces", "scala3-compiler", "scala3-library", "tasty-core", "scala3-tasty-inspector", "scaladoc")),
21352137
Compile / pack := republishPack.value,

project/RepublishPlugin.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,13 @@ object RepublishPlugin extends AutoPlugin {
215215
if (commandLibs.nonEmpty) {
216216
IO.createDirectory(republishDir / "etc")
217217
for ((command, libs) <- commandLibs) {
218-
val entries = libs.map(fuzzyFind(classpaths, _)).reduce(_ ++ _).distinct
218+
val (negated, actual) = libs.partition(_.startsWith("^!"))
219+
val subtractions = negated.map(_.stripPrefix("^!"))
220+
221+
def compose(libs: List[String]): List[String] =
222+
libs.map(fuzzyFind(classpaths, _)).reduceOption(_ ++ _).map(_.distinct).getOrElse(Nil)
223+
224+
val entries = compose(actual).diff(compose(subtractions))
219225
IO.write(republishDir / "etc" / s"$command.classpath", entries.mkString("\n"))
220226
}
221227
}

0 commit comments

Comments
 (0)