project and projects commands in sbt

While reviewing the source code of sbt, I stumbled upon sbt.CommandStrings. I’d swear I’d been looking at the class so many times yet it was only today when I noticed how powerful the commands – projects and project – are. Even the official documentation of sbt is almost silent on the commands.

I simply couldn’t resist let the #scala twitterland know how mind-boggling the news was to me.

tweet-about-sbt-project-command_2014-01-06_2203

So to let you gain a little wisdom about sbt, I’ll let their detailed help speak for themselves.

[root]> help project
project

  Displays the name of the current project.

project name

  Changes to the project with the provided name.
  This command fails if there is no project with the given name.

project {uri}

  Changes to the root project in the build defined by `uri`.
  `uri` must have already been declared as part of the build, such as with Project.dependsOn.

project {uri}name

  Changes to the project `name` in the build defined by `uri`.
  `uri` must have already been declared as part of the build, such as with Project.dependsOn.

project /

  Changes to the initial project.

project ..

  Changes to the parent project of the current project.
  If there is no parent project, the current project is unchanged.

  Use n+1 dots to change to the nth parent.
  For example, 'project ....' is equivalent to three consecutive 'project ..' commands.

[root]> help projects
projects
  List the names of available builds and the projects defined in those builds.

projects add <URI>+
  Adds the builds at the provided URIs to this session.
  These builds may be selected using the project command.
  Alternatively, tasks from these builds may be run using the explicit syntax {URI}project/task

projects remove <URI>+
  Removes extra builds from this session.
  Builds explicitly listed in the build definition are not affected by this command.

Questions? Comments? See you on StackOverflow.

Be Sociable, Share!
This entry was posted in Languages, Tools.

Leave a Reply

%d bloggers like this: