Fixes new command leaving target directory

Fixes #2835

This fixes `new` command creating `target` directory by moving the `target` to a staging directory in the command itself.
This commit is contained in:
Eugene Yokota 2018-03-24 13:45:35 -04:00
parent a43c18e4f9
commit b111b05d5f
1 changed files with 12 additions and 2 deletions

View File

@ -26,12 +26,22 @@ private[sbt] object TemplateCommandUtil {
private def templateCommandParser(state: State): Parser[Seq[String]] =
(token(Space) ~> repsep(StringBasic, token(Space))) | (token(EOF) map (_ => Nil))
private def runTemplate(state: State, inputArg: Seq[String]): State = {
private def runTemplate(s0: State, inputArg: Seq[String]): State = {
import BuildPaths._
val extracted0 = (Project extract s0)
val globalBase = getGlobalBase(s0)
val stagingDirectory = getStagingDirectory(s0, globalBase).getCanonicalFile
val templateStage = stagingDirectory / "new"
// This moves the target directory to a staging directory
// https://github.com/sbt/sbt/issues/2835
val state = extracted0.appendWithSession(Seq(
Keys.target := templateStage
),
s0)
val infos = (state get templateResolverInfos getOrElse Nil).toList
val log = state.globalLogging.full
val extracted = (Project extract state)
val (s2, ivyConf) = extracted.runTask(Keys.ivyConfiguration, state)
val globalBase = BuildPaths.getGlobalBase(state)
val scalaModuleInfo = extracted.get(Keys.scalaModuleInfo in Keys.updateSbtClassifiers)
val arguments = inputArg.toList ++
(state.remainingCommands match {