Deleted resources are not being removed from `.scala-build` and the classpath
Version(s) 0.1.2, also on e968a10797b2a14b835c6555ffc6c3d7aad14b10
Describe the bug
When --resource-dirs option or using directives is used resources are copied to the project directory in .scala-build, which is then put on a classpath. If the resource will then be deleted (or have it's name changed) and the project recompiled, the previous resource will not be removed from the .scala-build and can still be used in the program.
To Reproduce
reproduction/main.scala
//> using resourceDir "resources"
import java.nio.charset.StandardCharsets
import java.io.{BufferedReader, InputStreamReader}
import java.io.FileInputStream
@main def main(): Unit =
val inputStream = getClass().getResourceAsStream("/resourcefile.txt")
val text = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8)
).readLine()
println(text)
reproduction/resources/resource1
resource1
- Run
scala-cli project - Remove
project/resources/resource1file - Run
scala-cli project
Expected behaviour
Deleted resource files should be removed from .scala-build, and resource files with changed filenames should not be duplicated there - instead the previous version should be removed.
I imagine this is caused by the copyResourceToClassesDir in Build.scala, but I would rather not attempt at fixing that yet - I imagine the solution would be manually walking through the .scala-build directory and removing files that are neither source nor resource, but with the recent additions (native-image) I'm unsure what exactly would constitute a source (besides the obvious class, scala, tasty, nir, sjsir)