Yang Bo
Yang Bo

Reputation: 3723

How to write a Build.scala to change a SettingKey priviously assigned in build.sbt

I have a build.sbt:

name := "name"

And a project/Build.scala:

import sbt._
object MyBuild extends Build {
  val root = Project(id = "root", base = file("."))
  override def settings = super.settings :+ (
    Keys.name in root ~= { oldName => oldName + "-in-scala" }
  )
}

I want a transformer in project/Build.scala, which can changes name to name-in-scala. But it does not work.

How can I write a transformer in Build.scala?

Upvotes: 2

Views: 272

Answers (1)

Schleichardt
Schleichardt

Reputation: 7552

I don't think that's possible. The page http://www.scala-sbt.org/release/docs/Getting-Started/Full-Def.html#relating-build-sbt-to-build-scala states about SBT 0.12.1:

The setting in build.sbt should "win" over the one in Build.scala.

and

The settings in .sbt files are appended to the settings in .scala files.

Upvotes: 1

Related Questions