I have setup an example multi module project with an Build.scala:object TestProjectBuild extends Build {lazy val master =Project("master", file(".")) aggregate(sub1)lazy val sub1 =Project("sub1", file("sub1"))}The directory layout is:./project/Build.scala./sub1/build.sbt./sub1/src/test/resources/META-INF/spring/testContext.xml./sub1/src/test/scala/...In my sub module "sub1" I have tests that reference a file with a relative file path:@ContextConfiguration(locations = { "file:src/test/resources/META-INF/spring/testContext.xml" })
When I run the tests from the top level directory the tests fail because the file couldn't be found. If I run them from the sub1 directory the tests pass.
Calling 'base-directory' from the sbt console returns the correct base directories:
sub1/*:base-directory
/home/sebastian/sbt-playground/sub1
master/*:base-directory
/home/sebastian/sbt-playgroundNote that I can't use getClass.getResources in an annotation.
How can I configure sbt to make the tests work?
So. I believe using relative paths is always a danger, as I don't think you can change current working directory in java.
Sbt is not forking to run your tests, although you could do so and it would most likely fix your immediate issue.
Another possibility is to try to use the classsloader to pull in resources instead of file paths.
Hope that helps!
--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simple-build-t...@googlegroups.com.
To post to this group, send email to simple-b...@googlegroups.com.
Visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.