BuildInfo

Generate scala code from your buildfile. This plugin generates a single object containing information from your build.

To declare a module that uses BuildInfo you must extend the mill.contrib.buildinfo.BuildInfo trait when defining your module.

Quickstart:

build.mill
package build
import $ivy.`com.lihaoyi::mill-contrib-buildinfo:`
import mill.contrib.buildinfo.BuildInfo

object project extends BuildInfo with ScalaModule {
  val name = "project-name"
  val buildInfoPackageName = "com.organization"
  def buildInfoMembers = Seq(
    BuildInfo.Value("name", name),
    BuildInfo.Value("scalaVersion", scalaVersion()),
  )
}
Main.scala
import com.organization.BuildInfo

@main
def main = {
  println(BuildInfo.name)
  println(BuildInfo.scalaVersion)
}

The above example uses ScalaModule but BuildInfo can also be used with `JavaModule`s

Configuration options

  • def buildInfoMembers: T[Seq[BuildInfo.Value]] The map containing all member names and values for the generated info object.

  • def buildInfoObjectName: String, default: BuildInfo The name of the object which contains all the members from buildInfoMembers.

  • def buildInfoPackageName: String The package name of the object.