Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying files using SBT

Tags:

sbt

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
like image 445
Ankit Dhingra Avatar asked Jun 16 '12 16:06

Ankit Dhingra


1 Answers

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.

like image 183
nau Avatar answered Nov 21 '22 03:11

nau