0

I want to add some files to test a library that I am writing.

The tests are available in a compressed file in a URI and I just want to download that file and uncompress its contents to a folder before testing.

I was reading the documentation on SBT and there is a Generate sources/resources task.

Also, it seems easy to uncompress a zip file in Scala (see this question).

So I think, I could glue those 2 pieces together, but I wonder if there is some simpler solution.

Community
  • 1
  • 1
Labra
  • 1,412
  • 1
  • 13
  • 33

1 Answers1

2

How about this (syntax for Sbt 0.13.2), in your build.sbt:

resourceGenerators in Test += Def.task {
  val location = url("http://path/to/your/zip-file.zip")
  IO.unzipURL(location, resourceManaged.value / "my-custom-files").toSeq
}.taskValue
lpiepiora
  • 13,659
  • 1
  • 35
  • 47
  • Yes, it works. But the remark of using 0.13.2 syntax is important. I was using SBT 0.13.1 and it was giving me an error :) – Labra May 14 '14 at 20:18