[2.x] clean task cleans sona-staging (#9479)

**Problem/Solution**
1. clean task cleans sona-staging directory.
2. cleanFull calls clean task.
This commit is contained in:
eugene yokota 2026-07-23 22:30:16 -04:00 committed by GitHub
parent fc3666586a
commit 3520576a54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 0 deletions

View File

@ -760,6 +760,7 @@ object Defaults extends BuildCommon with DefExtra {
case NonFatal(_) => ()
}
clean.value
(ThisBuild / publish / clean).value
},
scalaCompilerBridgeBin := Def
.ifS(Def.task {

View File

@ -218,6 +218,7 @@ private[sbt] object Clean {
val h = Help.more(CleanFull, cleanFullDetailed)
val expunge: State => State =
(s: State) =>
import UpperStateOps.*
val outputDirectory = s
.get(BasicKeys.rootOutputDirectory)
.getOrElse(sys.error("outputDirectory has not been set"))
@ -225,6 +226,7 @@ private[sbt] object Clean {
cacheStore.foreach:
case d: DiskActionCacheStore => d.clear()
case _ => ()
val s2 = s.unsafeRunAggregated(LocalRootProject / clean)
IO.delete(outputDirectory.toFile())
IO.delete(
s.configuration

View File

@ -10,6 +10,9 @@ package sbt
package plugins
import Def.Setting
import Keys.*
import sbt.io.IO
import sbt.io.syntax.*
/**
* Plugin that enables resolving artifacts via ivy.
@ -29,6 +32,13 @@ object IvyPlugin extends AutoPlugin {
override lazy val globalSettings: Seq[Setting[?]] =
Defaults.globalIvyCore
override lazy val buildSettings: Seq[Setting[?]] =
Seq(
publish / clean := Def.uncached {
IO.delete(stagingDirectory.value)
IO.delete((ThisBuild / baseDirectory).value / "target" / "sona-bundle")
},
)
override lazy val projectSettings: Seq[Setting[?]] =
Classpaths.ivyPublishSettings ++ Classpaths.ivyBaseSettings

View File

@ -0,0 +1 @@
name := "clean-sona-staging"

View File

@ -0,0 +1,7 @@
$ touch target/sona-staging/dummy.txt
$ touch target/sona-bundle/dummy.txt
> clean
$ absent target/sona-staging/dummy.txt
$ absent target/sona-bundle/dummy.txt