-
Notifications
You must be signed in to change notification settings - Fork 1k
Make compile:clean clean only compilation artifacts #3542
Copy link
Copy link
Closed
Description
problem
You are an sbt user. You know of clean. You also know that tasks can be scoped in tasks.
You find yourself cleaning often, but most of the times you only want to clean compilation artifacts, and you want the rest of a project to be untouched.
You decide to be creative, and try compile::clean, expecting sbt to only clean the analysis files and the class files/jars created by the previous compilation.
sbt:sbtRoot> actionsProj/compile
[success] Total time: 2 s, completed Sep 16, 2017 12:22:20 AM
sbt:sbtRoot> actionsProj/compile:clean
[success] Total time: 0 s, completed Sep 16, 2017 12:22:33 AM
sbt:sbtRoot> actionsProj/compile
[info] Updating {file:/data/rw/code/scala/sbt/}actionsProj...
[info] Done updating.
[info] Formatting 10 Scala sources in actionsProj:compile ...
[info] Compiling 10 Scala sources to /data/rw/code/scala/sbt/main-actions/target/scala-2.12/classes ...
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Doc.scala:41:15: parameter value doc in method javadoc is never used
[warn] doc: JavaTools,
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Doc.scala:42:15: parameter value log in method javadoc is never used
[warn] log: Logger,
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Doc.scala:43:15: parameter value reporter in method javadoc is never used
[warn] reporter: Reporter,
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Sync.scala:70:13: pattern var target in value $anonfun is never used; `target@_' suppresses this warning
[warn] case (target, srcs) =>
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Sync.scala:31:13: parameter value outStyle in method apply is never used
[warn] outStyle: FileInfo.Style = FileInfo.exists)
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/TestResultLogger.scala:132:18: pattern var name in value $anonfun is never used; `name@_' suppresses this warning
[warn] (name, testEvent)) =>
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Tests.scala:156:14: pattern var a in value $anonfun is never used; `a@_' suppresses this warning
[warn] case a: Argument => // now handled by whatever constructs `runners`
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Tests.scala:295:18: parameter value tags in method makeSerial is never used
[warn] tags: Seq[(Tag, Int)]): Task[List[(String, SuiteResult)]] = {
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/ForkTests.scala:77:52: method ansiCodesSupported in class Logger is deprecated (since 1.0.0): No longer used.
[warn] val config = new ForkConfiguration(log.ansiCodesSupported, parallel)
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Package.scala:102:26: value IMPLEMENTATION_VENDOR_ID in object Name is deprecated: see corresponding Javadoc for more information.
[warn] IMPLEMENTATION_VENDOR_ID)
[warn] ^
[warn] /data/rw/code/scala/sbt/main-actions/src/main/scala/sbt/Package.scala:105:27: value IMPLEMENTATION_URL in object Name is deprecated: see corresponding Javadoc for more information.
[warn] homepage map (h => (IMPLEMENTATION_URL, h.toString))
[warn] ^
[warn] 11 warnings found
[info] Done compiling.
[success] Total time: 21 s, completed Sep 16, 2017 12:22:57 AM
But it doesn't work: sbt resolves the module again. You expected compile::clean to leave the cached files in target by resolution untouched.
expectation
compile:clean should clean only the compilation artifacts.
Benefits:
- sbt is more consistent, therefore more intuitive.
- sbt optimizes for a common use case and saves some times to the end users (resolution is expensive).
Reactions are currently unavailable