diff --git a/build.sbt b/build.sbt index 93ff16ba..0c66a4f1 100644 --- a/build.sbt +++ b/build.sbt @@ -9,16 +9,15 @@ import scala.io.Source import scala.util.Using name := "MapRouletteAPI" - -version := "4.0.0" - scalaVersion := "2.13.10" - Universal / packageName := "MapRouletteAPI" // Developers can run 'sbt format' to easily format their source; this is required to pass a PR build. addCommandAlias("format", "scalafmtAll; scalafmtSbt; scalafixAll") +enablePlugins(GitVersioning) +git.useGitDescribe := true + // Setup BuildInfo plugin to write important build-time values to a generated file (org.maproulette.models.service.info.BuildInfo) enablePlugins(BuildInfoPlugin) buildInfoPackage := "org.maproulette.models.service.info" @@ -32,6 +31,14 @@ buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion) buildInfoKeys += BuildInfoKey.action("buildDate")(LocalDate.now(ZoneOffset.UTC).toString) buildInfoKeys += BuildInfoKey.action("javaVersion")(sys.props("java.version")) buildInfoKeys += BuildInfoKey.action("javaVendor")(sys.props("java.vendor")) +buildInfoKeys += BuildInfoKey.action("gitDescribe")(git.gitDescribedVersion.value) +buildInfoKeys += BuildInfoKey.action("gitHasUncommitedChanges")(git.gitUncommittedChanges.value) +buildInfoKeys += BuildInfoKey.action("gitHeadCommit")(git.gitHeadCommit.value) +buildInfoKeys += BuildInfoKey.action("gitHeadCommitUrl")( + // The URL will not work if the commit is not pushed to the remote repository. + s"https://github.com/maproulette/maproulette-backend/commit/${git.gitHeadCommit.value.get}" +) +buildInfoKeys += BuildInfoKey.action("gitHeadCommitDate")(git.gitHeadCommitDate.value) // Configure scalastyle. This does not run during compile, run it with 'sbt scalastyle' or 'sbt test:scalastyle'. Compile / scalastyleConfig := baseDirectory.value / "conf/scalastyle-config.xml" diff --git a/project/plugins.sbt b/project/plugins.sbt index 2045744f..4fc3be8a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -17,3 +17,5 @@ addSbtPlugin("com.github.sbt" % "sbt-jacoco" % "3.4.0") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.3") addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0") + +addSbtPlugin("com.github.sbt" % "sbt-git" % "2.0.1")