CacheDirectory is deprecated at 0.13 ... so now?

Answering a question about this on the sbt mailing list, but apparently it crashed

I created a github project that works around "sbt> clean" from dropping the artifact update cache directory. Works great on 0.12.4, but broken in 0.13, my own update cache directory is empty after "sbt> update"

Which is equivalent:

cacheDirectory <<= baseDirectory / "sbt-no-clean" 

at 0.13? I see that cacheDirectory out of date and we will use streams instead.

Frequently Asked Questions SBT for 0.13 contains a section on using FileFunction.cached, is there a replacement for the above 1 liner? Does not look like it.

Streams can actually do this work, but since the old cacheDirectory no longer works - well, technically this attribute is set, but something overrides it, so this is more of a deletion than an obsolete function - - I switched gear and try to use cleanKeepFiles :

 cleanKeepFiles <<= (streams) map{s=> Seq(s.cacheDirectory)} 

I get a return type mismatch crazy in this, as I have no idea how to handle it:

 sbt.Def.Initialize[sbt.Task[Seq[java.io.File]]] 

in

 sbt.Def.Initialize[Seq[java.io.File]] 

Ideas appreciated, Thanks

EDIT
If you use the application instead of a map:

 cleanKeepFiles <<= streams.apply{_.map(x=>Seq(x.cacheDirectory))} 

then you will get:

 sbt.Task[Seq[java.io.File]] 

which seems to be approaching, but then the compiler wants:

 Seq[java.io.File] 

cleanKeepFiles is of type SettingKey[Seq[File]]

I do not understand how to get SettingKey[Seq[File]] from the stream type: TaskKey[TaskStreams]

+4
source share
2 answers

I completely forgot about the publication of this question, the solution was fortunately quite simple:

 cleanKeepFiles <+= base / pathToCacheDir 

This does not allow SBT to blow off the cache of prints on every single clean one, which saves several seconds on clean / compiled loops - a nice and easy WIN, just like we could work with cacheDirectory in SBT <= 0.12. 4

+2
source

Just changing cacheDirectory to target worked in my case:

from:

 cacheDirectory <<= baseDirectory / "sbt-no-clean" 

to

 target <<= baseDirectory / "sbt-no-clean" 
0
source

Source: https://habr.com/ru/post/1497664/


All Articles