[2.x] fix: Use strict matching for scala-library jar detection (#8507)

Fixes #7511

The previous check used contains("scala-library") which incorrectly
matched any jar with that substring anywhere in the filename, causing
user libraries named like "my-scala-library-foo" to be misclassified
as the Scala standard library and filtered from the classpath.

Changed to use exact match (scala-library.jar) or prefix match
(scala-library-*) to only match the actual Scala library jars,
consistent with how scala-reflect is detected on line 199.
This commit is contained in:
MkDev11 2026-01-12 23:50:01 -05:00 committed by GitHub
parent 3a9e1ec725
commit f2a5ae7219
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -182,8 +182,9 @@ private[sbt] object ClassLoaders {
cpFiles
.filter(f => {
val name = f.getName
name.contains(ArtifactInfo.ScalaLibraryID) || si.libraryJars
.exists(_.getName == name)
name == s"${ArtifactInfo.ScalaLibraryID}.jar" ||
name.startsWith(s"${ArtifactInfo.ScalaLibraryID}-") ||
si.libraryJars.exists(_.getName == name)
})
.toArray
else si.libraryJars