From a00a972c7425232432364bf991e118d248578f0d Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Wed, 8 Jun 2016 10:50:38 +0200 Subject: Add date and hash to publishing version --- project/Build.scala | 6 ++++-- project/VersionUtil.scala | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 project/VersionUtil.scala (limited to 'project') diff --git a/project/Build.scala b/project/Build.scala index c07fab230..85a7bb861 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -25,7 +25,8 @@ object DottyBuild extends Build { override def settings: Seq[Setting[_]] = { super.settings ++ Seq( scalaVersion in Global := "2.11.5", - version in Global := "0.1-SNAPSHOT", + version in Global := + "0.1-SNAPSHOT-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash, organization in Global := "ch.epfl.lamp", organizationName in Global := "LAMP/EPFL", organizationHomepage in Global := Some(url("http://lamp.epfl.ch")), @@ -208,7 +209,8 @@ object DottyBuild extends Build { "org.scala-sbt" % "api" % sbtVersion.value % "test", "org.specs2" %% "specs2" % "2.3.11" % "test" ), - version := "0.1.1-SNAPSHOT", + version := + "0.1.1-SNAPSHOT-" + VersionUtil.commitDate + "-" + VersionUtil.gitHash, // The sources should be published with crossPaths := false, the binaries // are unused so it doesn't matter. crossPaths := false, diff --git a/project/VersionUtil.scala b/project/VersionUtil.scala new file mode 100644 index 000000000..338cf2d95 --- /dev/null +++ b/project/VersionUtil.scala @@ -0,0 +1,18 @@ +import scala.sys.process.Process + +object VersionUtil { + def executeScript(scriptName: String) = { + val cmd = + if (System.getProperty("os.name").toLowerCase.contains("windows")) + s"cmd.exe /c scripts\\build\\$scriptName.bat -p" + else s"scripts/build/$scriptName" + Process(cmd).lines.head.trim + } + + /** Seven letters of the SHA hash is considered enough to uniquely identify a + * commit, albeit extremely large projects - such as the Linux kernel - need + * more letters to stay unique + */ + def gitHash = executeScript("get-scala-commit-sha").substring(0, 7) + def commitDate = executeScript("get-scala-commit-date") +} -- cgit v1.2.3