Asked this on the sbt mailing list, but apparently it is being phased out
I created a project on github that works around "sbt> clean" from blowing away artifact update cache directory. Works great on 0.12.4, but broken in 0.13, my custom update cache directory is empty after "sbt> update"
What's the equivalent of:
cacheDirectory <<= baseDirectory / "sbt-no-clean"
in 0.13? I see that cacheDirectory
has been deprecated and that we are to use streams
instead.
The SBT FAQ for 0.13 has a section on using FileFunction.cached, is that the replacement for above 1 liner? Doesn't look like it.
Streams may indeed do the job, but since old method of working with cacheDirectory
no longer works -- well, technically the attribute is set, but something overrides it, so it's more of a removal than deprecation functionality-wise -- I have shifted gears and am trying to use cleanKeepFiles
:
cleanKeepFiles <<= (streams) map{s=> Seq(s.cacheDirectory)}
I get a return type mismatch, a maddening one at that, as I have no idea how to turn:
sbt.Def.Initialize[sbt.Task[Seq[java.io.File]]]
into
sbt.Def.Initialize[Seq[java.io.File]]
Ideas appreciated, Thanks
EDIT
If you use apply instead of map:
cleanKeepFiles <<= streams.apply{_.map(x=>Seq(x.cacheDirectory))}
then you get:
sbt.Task[Seq[java.io.File]]
which seems to be getting closer, but then the compiler wants:
Seq[java.io.File]
cleanKeepFiles
is of type SettingKey[Seq[File]]
I am beyond confused as to how to get a SettingKey[Seq[File]]
out of stream's type: TaskKey[TaskStreams]
Totally forgot about posting this question, solution was thankfully pretty simple:
cleanKeepFiles <+= base / pathToCacheDir
That prevents SBT from blowing away deps cache on every single clean, which shaves a few seconds off clean/compile cycles -- a nice & easy WIN, just like we were able to do with cacheDirectory in SBT <= 0.12.4
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