I want to migrate a Maven project to Play 2/sbt:
I had some resources for tests in src/test/resources
in the Maven project, which I moved to test/resources/
in the Play project (thanks to Schleichardt for his answer on Stackoverflow).
This works for normal files (text, binary data...), but now I have problems with Java-Source files that are also in the test/resources/
directory (I have to test a Java parser in my project on different java source files). When I call test
in play, these files will also get compiled and so I get errors.
How can I prevent that the files in test/resources/
will get compiled from Play/sbt?
Since your test resource directory is in a directory that compiles java sources you could move your test resource folder. Add this to your settings:
resourceDirectory in Test <<= (baseDirectory) apply {(baseDir: File) => baseDir / "testResources"}
For example in project/Build.scala:
val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
resourceDirectory in Test <<= (baseDirectory) apply {(baseDir: File) => baseDir / "testResources"}
)
Control your changes in the console with:
play "show test:resource-directory"
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