summaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
Diffstat (limited to 'project')
-rw-r--r--project/MiMa.scala2
-rw-r--r--project/PartestUtil.scala6
-rw-r--r--project/VersionUtil.scala69
-rw-r--r--project/plugins.sbt5
4 files changed, 58 insertions, 24 deletions
diff --git a/project/MiMa.scala b/project/MiMa.scala
index fb9bb175ab..a47856b1fd 100644
--- a/project/MiMa.scala
+++ b/project/MiMa.scala
@@ -51,7 +51,7 @@ object MiMa {
"--curr", curr.getAbsolutePath,
"--filters", filter.getAbsolutePath,
"--generate-filters",
- // !!! Command line MiMa (which we call rathan the sbt Plugin for reasons alluded to in f2d0f1e85) incorrectly
+ // !!! Command line MiMa (which we call rather than the sbt Plugin for reasons alluded to in f2d0f1e85) incorrectly
// defaults to no checking (!) if this isn't specified. Fixed in https://github.com/typesafehub/migration-manager/pull/138
// TODO: Try out the new "--direction both" mode of MiMa
"--direction", "backwards"
diff --git a/project/PartestUtil.scala b/project/PartestUtil.scala
index 127dcafefa..40031192e4 100644
--- a/project/PartestUtil.scala
+++ b/project/PartestUtil.scala
@@ -26,6 +26,10 @@ object PartestUtil {
isParentOf(testBase / srcPath, f, 2) || isParentOf(f, testBase / srcPath, Int.MaxValue)
}
}
+
+ def testFilePaths(globalBase: File, testBase: File): Seq[java.io.File] =
+ (new TestFiles("files", globalBase, testBase)).allTestCases.map(_._1)
+
/** A parser for the custom `partest` command */
def partestParser(globalBase: File, testBase: File): Parser[String] = {
val knownUnaryOptions = List(
@@ -83,7 +87,7 @@ object PartestUtil {
token(grepOption <~ Space) ~> token(globOrPattern, tokenCompletion)
}
- val SrcPath = ((token(srcPathOption) <~ Space) ~ token(StringBasic.examples(Set("files", "pending", "scaladoc")))) map {
+ val SrcPath = ((token(srcPathOption) <~ Space) ~ token(StringBasic.examples(Set("files", "scaladoc")))) map {
case opt ~ path =>
srcPath = path
opt + " " + path
diff --git a/project/VersionUtil.scala b/project/VersionUtil.scala
index ebc2488345..aacbc78329 100644
--- a/project/VersionUtil.scala
+++ b/project/VersionUtil.scala
@@ -2,8 +2,10 @@ package scala.build
import sbt._
import Keys._
-import java.util.Properties
+import java.util.{Date, Locale, Properties, TimeZone}
import java.io.{File, FileInputStream}
+import java.text.SimpleDateFormat
+
import scala.collection.JavaConverters._
import BuildSettings.autoImport._
@@ -51,19 +53,21 @@ object VersionUtil {
/** Compute the canonical, Maven and OSGi version number from `baseVersion` and `baseVersionSuffix`.
* Examples of the generated versions:
*
- * ("2.11.8", "SNAPSHOT" ) -> ("2.11.8-20151215-133023-7559aed", "2.11.8-SNAPSHOT", "2.11.8.v20151215-133023-7559aed")
- * ("2.11.8", "SHA-SNAPSHOT") -> ("2.11.8-20151215-133023-7559aed", "2.11.8-7559aed-SNAPSHOT", "2.11.8.v20151215-133023-7559aed")
- * ("2.11.8", "SHA-NIGHTLY" ) -> ("2.11.8-7559aed-nightly", "2.11.8-7559aed-nightly", "2.11.8.v20151215-133023-NIGHTLY-7559aed")
- * ("2.11.8", "" ) -> ("2.11.8", "2.11.8", "2.11.8.v20151215-133023-VFINAL-7559aed")
- * ("2.11.8", "M3" ) -> ("2.11.8-M3", "2.11.8-M3", "2.11.8.v20151215-133023-M3-7559aed")
- * ("2.11.8", "RC4" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed")
- * ("2.11.8-RC4", "SPLIT" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed")
+ * ("2.11.8", "SNAPSHOT" ) -> ("2.11.8-20151215-133023-7559aed", "2.11.8-bin-SNAPSHOT", "2.11.8.v20151215-133023-7559aed")
+ * ("2.11.8", "SHA-SNAPSHOT") -> ("2.11.8-20151215-133023-7559aed", "2.11.8-bin-7559aed-SNAPSHOT", "2.11.8.v20151215-133023-7559aed")
+ * ("2.11.8", "SHA" ) -> ("2.11.8-7559aed", "2.11.8-bin-7559aed", "2.11.8.v20151215-133023-7559aed")
+ * ("2.11.0", "SHA" ) -> ("2.11.0-7559aed", "2.11.0-pre-7559aed", "2.11.0.v20151215-133023-7559aed")
+ * ("2.11.8", "" ) -> ("2.11.8", "2.11.8", "2.11.8.v20151215-133023-VFINAL-7559aed")
+ * ("2.11.8", "M3" ) -> ("2.11.8-M3", "2.11.8-M3", "2.11.8.v20151215-133023-M3-7559aed")
+ * ("2.11.8", "RC4" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed")
+ * ("2.11.8-RC4", "SPLIT" ) -> ("2.11.8-RC4", "2.11.8-RC4", "2.11.8.v20151215-133023-RC4-7559aed")
*
* A `baseVersionSuffix` of "SNAPSHOT" is the default, which is used for local snapshot builds. The PR validation
- * job uses "SHA-SNAPSHOT". A proper version number for a nightly build can be computed with "SHA-nightly". An empty
+ * job uses "SHA-SNAPSHOT". A proper version number for an integration build can be computed with "SHA". An empty
* suffix is used for releases. All other suffix values are treated as RC / milestone builds. The special suffix
* value "SPLIT" is used to split the real suffix off from `baseVersion` instead and then apply the usual logic. */
private lazy val versionPropertiesImpl: Def.Initialize[Versions] = Def.setting {
+ val log = sLog.value
val (base, suffix) = {
val (b, s) = (baseVersion.value, baseVersionSuffix.value)
@@ -74,23 +78,44 @@ object VersionUtil {
} else (b, s)
}
- def executeTool(tool: String) = {
- val cmd =
- if (System.getProperty("os.name").toLowerCase.contains("windows"))
- s"cmd.exe /c tools\\$tool.bat -p"
- else s"tools/$tool"
- Process(cmd).lines.head
+ val (dateObj, sha) = {
+ try {
+ // Use JGit to get the commit date and SHA
+ import org.eclipse.jgit.storage.file.FileRepositoryBuilder
+ import org.eclipse.jgit.revwalk.RevWalk
+ val db = new FileRepositoryBuilder().findGitDir.build
+ val head = db.resolve("HEAD")
+ if(head eq null) {
+ log.info("No git HEAD commit found -- Using current date and 'unknown' SHA")
+ (new Date, "unknown")
+ } else {
+ val commit = new RevWalk(db).parseCommit(head)
+ (new Date(commit.getCommitTime.toLong * 1000L), commit.getName.substring(0, 7))
+ }
+ } catch { case ex: Exception =>
+ log.error("Could not determine commit date + SHA: "+ex)
+ log.trace(ex)
+ (new Date, "unknown")
+ }
+ }
+ val date = {
+ val df = new SimpleDateFormat("yyyyMMdd-HHmmss", Locale.ENGLISH)
+ df.setTimeZone(TimeZone.getTimeZone("UTC"))
+ df.format(dateObj)
}
- val date = executeTool("get-scala-commit-date")
- val sha = executeTool("get-scala-commit-sha").substring(0, 7)
+ val Patch = """\d+\.\d+\.(\d+)""".r
+ def cross = base match {
+ case Patch(p) if p.toInt > 0 => "bin"
+ case _ => "pre"
+ }
val (canonicalV, mavenSuffix, osgiV, release) = suffix match {
- case "SNAPSHOT" => (s"$base-$date-$sha", s"-SNAPSHOT", s"$base.v$date-$sha", false)
- case "SHA-SNAPSHOT" => (s"$base-$date-$sha", s"-$sha-SNAPSHOT", s"$base.v$date-$sha", false)
- case "SHA-NIGHTLY" => (s"$base-$sha-nightly", s"-$sha-nightly", s"$base.v$date-NIGHTLY-$sha", true)
- case "" => (s"$base", "", s"$base.v$date-VFINAL-$sha", true)
- case suffix => (s"$base-$suffix", s"-$suffix", s"$base.v$date-$suffix-$sha", true)
+ case "SNAPSHOT" => (s"$base-$date-$sha", s"-$cross-SNAPSHOT", s"$base.v$date-$sha", false)
+ case "SHA-SNAPSHOT" => (s"$base-$date-$sha", s"-$cross-$sha-SNAPSHOT", s"$base.v$date-$sha", false)
+ case "SHA" => (s"$base-$sha", s"-$cross-$sha", s"$base.v$date-$sha", false)
+ case "" => (s"$base", "", s"$base.v$date-VFINAL-$sha", true)
+ case suffix => (s"$base-$suffix", s"-$suffix", s"$base.v$date-$suffix-$sha", true)
}
Versions(canonicalV, base, mavenSuffix, osgiV, sha, date, release)
diff --git a/project/plugins.sbt b/project/plugins.sbt
index ca80c88a9e..58e2d6cdad 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -21,6 +21,11 @@ buildInfoPackage := "scalabuild"
libraryDependencies += "com.typesafe" %% "mima-reporter" % "0.1.13"
+libraryDependencies ++= Seq(
+ "org.eclipse.jgit" % "org.eclipse.jgit" % "4.6.0.201612231935-r",
+ "org.slf4j" % "slf4j-nop" % "1.7.23"
+)
+
concurrentRestrictions in Global := Seq(
Tags.limitAll(1) // workaround for https://github.com/sbt/sbt/issues/2970
)