Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BuildInfo is not generated using sbt 1.3.13 #166

Open
rohit5ram opened this issue Sep 29, 2020 · 3 comments
Open

BuildInfo is not generated using sbt 1.3.13 #166

rohit5ram opened this issue Sep 29, 2020 · 3 comments

Comments

@rohit5ram
Copy link

project/plugins.sbt

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.0")
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0")

build.sbt

lazy val root = (project in file(".")).enablePlugins(PlayScala)
  .enablePlugins(BuildInfoPlugin).settings(
    buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
    buildInfoPackage := "version"
  )

BuildInfo is never generated

@filipmacek
Copy link

Same here.

@Stivo
Copy link

Stivo commented Oct 11, 2020

It also didn't work in my project. I replaced it with following code in the build.sbt file:

lazy val generateBuildInfo = taskKey[Seq[File]]("Generates the build information")

generateBuildInfo := {
  val file = (resourceManaged in Compile).value / "buildinfo.properties"
  IO.write(file,
    s"""
       |version = ${version.value}
       |scalaVersion = ${scalaVersion.value}
       |sbtVersion = ${sbtVersion.value}
       |builtAt = ${new Date()}
       |builtAtMillis = ${System.currentTimeMillis()}
       |""".stripMargin)
  Seq(file)
}

resourceGenerators in Compile += generateBuildInfo

This will generate a buildinfo.properties file, which you can then read from the source code to get the desired values. I am sure it could be changed to generate the object directly, but this worked for me.

@filipmacek
Copy link

Also I noticed strange thing, src_managed directory wont be created if I build project using Intelij "Build project" button but If I compile project using "sbt compile" eveything is all right. Aren't they supposed to be the same ways of compiling the sbt project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants