Skip to content

Commit 93e22c0

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

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
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: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,15 @@ goto :eof
8989
@rem output parameter: _JVM_CP_ARGS
9090
:compilerJavaClasspathArgs
9191

92-
call :loadClasspathFromFile
92+
call :loadClasspathFromFile "scala"
9393

94-
set "__TOOLCHAIN=%_CLASS_PATH%"
94+
set "__TOOLCHAIN=%_CLASS_PATH_RESULT%"
95+
96+
call :loadClasspathFromFile "with_compiler"
97+
98+
if defined _CLASS_PATH_RESULT (
99+
set "__TOOLCHAIN=%__TOOLCHAIN%%_PSEP%%_CLASS_PATH_RESULT%"
100+
)
95101

96102
if defined _SCALA_CPATH (
97103
set "_JVM_CP_ARGS=%__TOOLCHAIN%%_SCALA_CPATH%"
@@ -101,16 +107,18 @@ if defined _SCALA_CPATH (
101107
goto :eof
102108

103109
@REM concatentate every line in "%_ETC_DIR%\scala.classpath" with _PSEP
110+
@REM arg 1 - file to read
104111
:loadClasspathFromFile
105-
set _CLASS_PATH=
106-
if exist "%_ETC_DIR%\scala.classpath" (
107-
for /f "usebackq delims=" %%i in ("%_ETC_DIR%\scala.classpath") do (
112+
set _ARG_FILE=%1
113+
set _CLASS_PATH_RESULT=
114+
if exist "%_ETC_DIR%\%_ARG_FILE%.classpath" (
115+
for /f "usebackq delims=" %%i in ("%_ETC_DIR%\%_ARG_FILE%.classpath") do (
108116
set "_LIB=%_PROG_HOME%\maven2\%%i"
109117
set "_LIB=!_LIB:/=\!"
110-
if not defined _CLASS_PATH (
111-
set "_CLASS_PATH=!_LIB!"
118+
if not defined _CLASS_PATH_RESULT (
119+
set "_CLASS_PATH_RESULT=!_LIB!"
112120
) else (
113-
set "_CLASS_PATH=!_CLASS_PATH!%_PSEP%!_LIB!"
121+
set "_CLASS_PATH_RESULT=!_CLASS_PATH_RESULT!%_PSEP%!_LIB!"
114122
)
115123
)
116124
)

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)