Dale Wijnand
Dale Wijnand

Reputation: 6102

How to set settings for a subproject in sbt shell (without using project command)?

In sbt shell how do I set a setting for a subproject?

I know I can project subproject then set key := value, but I don't want to have to keep switching projects. Ideally something not too different from:

set key in subproject := value

Upvotes: 6

Views: 1277

Answers (1)

lpiepiora
lpiepiora

Reputation: 13749

I think the problem is that you have defined your projects in build.sbt, and they seem not to be visible in the sbt console. At least in the current version of sbt - see this issue and this issue that were in fact fixed just a couple of days ago (!)

I have found two ways to overcome this limitation.

Use quotes around the project id

set version in "projectId" := "some-version"

Create a full build definition in project/Build.scala file

With the following build definition file build/Build.scala:

import sbt._
import Keys._

object Build extends Build {
  lazy val projectA, projectB = project
}

you should be fine to execute set version in projectA := "1.42-SNAPSHOT with the expected effect.

Additionally you could just have the build/Build.scala containing the project definition and rest of the configuration have in build.sbt for each submodule. It'd work perfectly fine with set.

Upvotes: 8

Related Questions