Fix compile-clean partially

There is still no auto-definition of clean on tasks that return Seq[Path]
This commit is contained in:
Adrien Piquerez 2024-03-26 14:35:01 +01:00
parent 0005705eb6
commit 84b933802e
3 changed files with 24 additions and 23 deletions

View File

@ -1,5 +1,6 @@
import sbt.nio.file.Glob
ThisBuild / scalaVersion := "2.12.17"
name := "compile-clean"
scalaVersion := "2.12.17"
Compile / cleanKeepGlobs +=
Glob((Compile / compile / classDirectory).value, "X.class")

View File

@ -1,22 +0,0 @@
$ touch target/cant-touch-this
> Test/compile
$ exists target/scala-2.12/classes/A.class
$ exists target/scala-2.12/test-classes/B.class
> Test/clean
$ exists target/cant-touch-this
# it should clean only compile classes
$ exists target/scala-2.12/classes/A.class
$ exists target/scala-2.12/classes/X.class
$ absent target/scala-2.12/test-classes/B.class
# compiling everything again, but now cleaning only compile classes
> Test/compile
> Compile/clean
$ exists target/cant-touch-this
# it should clean only compile classes
$ absent target/scala-2.12/classes/A.class
$ exists target/scala-2.12/test-classes/B.class
# and X has to be kept, because of the cleanKeepFiles override
$ exists target/scala-2.12/classes/X.class

View File

@ -0,0 +1,22 @@
$ touch target/cant-touch-this
> Test/products
$ exists target/out/jvm/scala-2.12.17/compile-clean/classes/A.class
$ exists target/out/jvm/scala-2.12.17/compile-clean/test-classes/B.class
> Test/clean
$ exists target/cant-touch-this
# TODO it should clean only test classes
# $ exists target/out/jvm/scala-2.12.17/compile-clean/classes/A.class
# $ exists target/out/jvm/scala-2.12.17/compile-clean/classes/X.class
$ absent target/out/jvm/scala-2.12.17/compile-clean/test-classes/B.class
# compiling everything again, but now cleaning only compile classes
> Test/products
> Compile/clean
$ exists target/cant-touch-this
# TODO it should clean only compile classes
$ absent target/out/jvm/scala-2.12.17/compile-clean/classes/A.class
# $ exists target/out/jvm/scala-2.12.17/compile-clean/test-classes/B.class
# TODO and X has to be kept, because of the cleanKeepFiles override
# $ exists target/out/jvm/scala-2.12.17/compile-clean/classes/X.class