Reputation: 12899
How do I add the resourceDirectory
in Java Classpath while SBT runs tests?
For now I only have sbt jar.
My need is due to a dependency (spark-cassandra-connector EmbeddedCassandra) loading a resource via ClassLoader.getSystemResourceAsStream
rather than getClass().getClassLoader().getResource
...
Upvotes: 2
Views: 2339
Reputation: 8996
If you want to add a new file/folder to your Java Classpth you can add the following line in your build.sbt
:
(fullClasspath in Test) := (fullClasspath in Test).value ++ Seq(Attributed.blank((resourceDirectory in Test).value))
This will add the folder given by the test:resourceDirectory
setting to the Classpath under the Test
configuration.
Note:
The fullClasspath task provides a classpath including both the dependencies and the products of a project. For the test classpath, this includes the main and test resources and compiled classes for the project as well as all dependencies for testing.
...
fullClasspath is the concatenation of
dependencyClasspath
andexportedProducts
More details can be found here.
Upvotes: 1