2
votes

I have the following build:

  lazy val stampleSearchProject = RootProject(file("../stample-search"))


  lazy val main = play.Project(appName, appVersion, appDependencies)
    .dependsOn(stampleSearchProject)
    .settings(defaultScalaSettings:_*)
    .settings( ......... )

The stample-search project has a build.sbt file with name := "stample-search"

I have found in the SBT documentation:

Navigating projects interactively: At the sbt interactive prompt, type projects to list your projects and project to select a current project. When you run a task like compile, it runs on the current project. So you don't necessarily have to compile the root project, you could compile only a subproject.

But the SBT documentation doesn't use RootProject but uses Project instead (which seems to require to use a project path inside the root project, I mean I can't use ../my-project)

So I tried this.

[Stample] $ projects
[info] In file:/home/sebastien/Bureau/Stample/stample-web/
[info]   * Stample
[info] In file:/home/sebastien/Bureau/Stample/stample-search/
[info]     default-ccdbaa

So it seems to list both projects but I'd like to know where come this name default-ccdbaa

Then I try to use the project command

[Stample] $ project Stample
[info] Set current project to Stample (in build file:/home/sebastien/Bureau/Stample/stample-web/)

[Stample] $ project default-ccdbaa
[error] Invalid project name 'default-ccdbaa' in build file:/home/sebastien/Bureau/Stample/stample-web/ (type 'projects' to list available projects).

[Stample] $ project stample-search
[error] Invalid project name 'stample-search' in build file:/home/sebastien/Bureau/Stample/stample-web/ (type 'projects' to list available projects).

It doesn't seem to work. Can someone explain me what's wrong with my build?

1

1 Answers

3
votes

For details, you probably have to read Full Configuration (Draft) : Project Relationships

There are three kinds of project relationships in sbt. These are described by execution, classpath, and configuration dependencies. ...

RootProject defines a project reference, not a subproject. So you're effectively creating a source-level dependency, but you can't switch into it. A better approach would be to use plain Multi-Project build.

import sbt._
import Keys._

object HelloBuild extends Build {
  lazy val root = Project(id = "hello",
                          base = file(".")) aggregate(foo, bar)

  lazy val foo = Project(id = "hello-foo",
                         base = file("foo"))

  lazy val bar = Project(id = "hello-bar",
                         base = file("bar"))
}