Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c6b7e59d7f
Fetching contributors…

Cannot retrieve contributors at this time

78 lines (51 sloc) 1.601 kb

sbt-buildinfo

I know this because build.sbt knows this.

sbt-buildinfo generates Scala source from your build definitions.

Latest

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.1.2")

Usage

Add the following in your build.sbt:

buildInfoSettings

sourceGenerators in Compile <+= buildInfo

buildInfoKeys := Seq[Scoped](name, version, scalaVersion, sbtVersion)

buildInfoPackage := "hello"

When you reload the settings and compile, this generates the following:

package hello

object BuildInfo {
  val name = "helloworld"
  val version = "0.1-SNAPSHOT"
  val scalaVersion = "2.9.1"
  val sbtVersion = "0.11.2"
}

Customize buildInfoKeys by adding whatever keys.

buildInfoKeys ++= Seq[Scoped](resolvers, libraryDependencies in Test)

This generates:

  val resolvers = Seq("Sonatype Public: https://oss.sonatype.org/content/groups/public")
  val test_libraryDependencies = Seq("org.scala-lang:scala-library:2.9.1", ...)

Tasks can be added only if they do not depend on sourceGenerators. Otherwise, it will cause an infinite loop.

Here's how to change the generated the object name:

buildInfoObject  := "Info"

This change to object Info. Changing the object name is optional, but to avoid name clash with other jars, package name should be changed.

build number

A build number can be generated as follows. Note that cross building against multiple Scala would each generate new number.

buildInfoKeys += buildInfoBuildNumber

License

MIT License

Jump to Line
Something went wrong with that request. Please try again.