You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
16:30 λ cat build.sbt
// Scala CLI doesn't distinguish main and test sources for now.
Test / sources ++= (Compile / sources).value
scalaVersion := "3.0.2"
Compile / unmanagedClasspath ++= Seq(file("/Users/jteigen/Development/cli-resource/resources"))
Runtime / unmanagedClasspath ++= Seq(file("/Users/jteigen/Development/cli-resource/resources"))
16:30 λ sbt run
[info] welcome to sbt 1.5.5 (Homebrew Java 11.0.12)
[info] loading global plugins from /Users/jteigen/.sbt/1.0/plugins
[info] loading project definition from /Users/jteigen/Development/cli-resource/dest/project
[info] loading settings for project dest from build.sbt ...
[info] set current project to dest (in build file:/Users/jteigen/Development/cli-resource/dest/)
[info] compiling 1 Scala source to /Users/jteigen/Development/cli-resource/dest/target/scala-3.0.2/classes ...
[info] running main
file:/Users/jteigen/Development/cli-resource/dest/target/bg-jobs/sbt_a8cc4955/target/0020f180/a4662cdd/resources/data.txt
[success] Total time: 4 s, completed Dec 17, 2021, 4:30:56 PM
Running it works. But just like with scala-cli run it find the file on the filesystem, not in the jar.
Inspecting the jar reveals why
16:31 λ cat build.sbt
// Scala CLI doesn't distinguish main and test sources for now.
Test / sources ++= (Compile / sources).value
scalaVersion := "3.0.2"
Compile / unmanagedResourceDirectories ++= Seq(file("/Users/jteigen/Development/cli-resource/resources"))
Running shows that the resource file is now resolved from the jar-file, not the filesystem.
16:32 λ sbt run
[info] welcome to sbt 1.5.5 (Homebrew Java 11.0.12)
[info] loading global plugins from /Users/jteigen/.sbt/1.0/plugins
[info] loading project definition from /Users/jteigen/Development/cli-resource/dest/project
[info] loading settings for project dest from build.sbt ...
[info] set current project to dest (in build file:/Users/jteigen/Development/cli-resource/dest/)
[info] running main
jar:file:/Users/jteigen/Development/cli-resource/dest/target/bg-jobs/sbt_c7561821/job-1/target/4ed69241/c326b934/dest_3-0.1.0-SNAPSHOT.jar!/data.txt
[success] Total time: 1 s, completed Dec 17, 2021, 4:32:14 PM
ScalaCLI by default copy all files from build.output directory to bootstrap file - link
Build.output is the path to classesDir in bloop. And there is problem, that bloop not copy resource files to clasessDir. Therefore resourceDir doesn't work with the package command.
I reported this problem to the bloop repository - #1631
Thanks for @teigen detailed description of the problem
https://gist.github.com/teigen/16059fa6413a023d939d7ed35925a613
The text was updated successfully, but these errors were encountered: