I am using SBT for building a java project and have a requirement of copying text files (that are not resources, but used by java classes to read instead). I am inexperienced with either SBT or Scala (needed for build.scala file) Any help would be really appreciated.
For example, if my directory structure is:
test
|- files
|- one.text
|- main
|- java
|- Test.java
I want the one.text file available as well in the target folder once I execute an sbt goal like
sbt test
Following lines in your build.sbt should do the trick:
unmanagedResourceDirectories in Test <+= (baseDirectory) {_ / "files"}
unmanagedSourceDirectories in Test <+= (baseDirectory) {_ / "main" / "java"}
You have a non standard project layout though. If you can change it to a standard "maven style":
project/src/main/java
project/src/main/resources
project/src/test/java/{Test.java, ...}
project/src/test/resources/{one.text, ...}
sbt will do resource copying automatically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With