Merge pull request #8394 from eed3si9n/wip/repro-resource

[2.x] fix: Fixes managed resources missing from the JAR
This commit is contained in:
eugene yokota 2025-11-29 01:38:31 -05:00 committed by GitHub
commit ba8acdd27c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 0 deletions

View File

@ -4084,6 +4084,7 @@ object Classpaths {
val resourceDirs = resourceDirectories.value
val vfBackendDir = compileIncremental.value._2
val backendDir = c.toPath(vfBackendDir)
val _ = resources.value
backendDir.toFile() :: resourceDirs.toList.filter(_.exists())
}

View File

@ -0,0 +1,3 @@
import sbt.*
object A extends AutoPlugin

View File

@ -0,0 +1,23 @@
scalaVersion := "3.7.4"
organization := "com.example"
@transient
lazy val check = taskKey[Unit]("extract jar file")
lazy val a = (project in file("a"))
.enablePlugins(SbtPlugin)
.settings(
name := "a",
check := Def.uncached {
val converter = fileConverter.value
val p = converter.toPath((Compile / packageBin).value)
val outDir = target.value / "extracted"
IO.unzip(p.toFile(), outDir)
val expectedResource = outDir / "sbt" / "sbt.autoplugins"
if !expectedResource.exists() then
sys.error(s"$expectedResource doesn't exist")
val content = IO.read(outDir / "sbt" / "sbt.autoplugins").trim
assert(content == "A", s"expected A, but content was '$content'")
},
)

View File

@ -0,0 +1,2 @@
> a/packageBin
> a/check