shawnuser3862921
shawnuser3862921

Reputation: 127

How to list all configurations with their description?

I use sbt 0.13.5.

From the sbt console, how can one see a list of all the defined configurations in a project (e.g. Compile, Test, etc) and their description?

Upvotes: 7

Views: 1550

Answers (2)

yiksanchan
yiksanchan

Reputation: 1940

A simpler version that simply works:

// Add below snippet to your build.sbt
lazy val printConfig = taskKey[Unit]("Print config")
printConfig := {
  val conf = ConfigFactory.load()
  println(conf)
}

Then run printConfig in your sbt console.

Upvotes: -2

lpiepiora
lpiepiora

Reputation: 13749

I don't know if there is a built-in command for that. Unless there is one, you could create a task doing just that:

build.sbt

lazy val showConfigurations = taskKey[Unit]("Shows all configurations")

lazy val inAnyProjectAndConfiguration = ScopeFilter(inAnyProject, inAnyConfiguration)

showConfigurations := {
  val configs = configuration.all(inAnyProjectAndConfiguration).value.toSet
  configs.filter(_.isPublic).foreach(c => println(s"${c.name} ${c.description}"))
}

You may not see descriptions for some configurations, because it's not mandatory. As a matter of fact, it seems that none of the default ones have it.

Upvotes: 8

Related Questions