Make sbtBinaryVersion use the new approach for 0.13 and later to support cross-building plugins.

This commit is contained in:
Mark Harrah
2013-05-31 09:34:13 -04:00
parent a4b2c14dcf
commit c2bfb182d2
2 changed files with 26 additions and 2 deletions
+24
View File
@@ -81,6 +81,30 @@ object CrossVersion
def binaryScalaVersion(full: String): String = binaryVersion(full, TransitionScalaVersion)
def binarySbtVersion(full: String): String = binaryVersion(full, TransitionSbtVersion)
private[sbt] def binarySbtVersionFuture(full: String): String = sbtApiVersion(full) match {
case Some((x,y)) => x + "." + y
case None => full
}
private[this] def sbtApiVersion(v: String): Option[(Int, Int)] =
{
val ReleaseV = """(\d+)\.(\d+)\.(\d+)(-\d+)?""".r
val CandidateV = """(\d+)\.(\d+)\.(\d+)(-RC\d+)""".r
val NonReleaseV = """(\d+)\.(\d+)\.(\d+)(-\w+)""".r
v match {
// before 0.12, the full sbt version was used
case PartialVersion(x, y) if (x.toInt == 0 && y.toInt < 12) => None
// 0.12 uses x.y always, regardless of release status
case PartialVersion(x, y) if (x.toInt == 0 && y.toInt == 12) => Some((x.toInt, y.toInt))
// 0.13 and later behavior
case ReleaseV(x, y, z, ht) => Some((x.toInt, y.toInt))
case CandidateV(x, y, z, ht) => Some((x.toInt, y.toInt))
case NonReleaseV(x, y, z, ht) if z.toInt > 0 => Some((x.toInt, y.toInt))
// otherwise, use the full version
case _ => None
}
}
def binaryVersion(full: String, cutoff: String): String =
{
def sub(major: Int, minor: Int) = major + "." + minor
+2 -2
View File
@@ -11,7 +11,7 @@ package sbt
import Load.LoadedBuild
import Artifact.{DocClassifier, SourceClassifier}
import Configurations.{Compile, CompilerPlugin, IntegrationTest, names, Provided, Runtime, Test}
import CrossVersion.{binarySbtVersion, binaryScalaVersion}
import CrossVersion.{binarySbtVersionFuture, binaryScalaVersion}
import complete._
import std.TaskExtra._
import inc.{FileValueCache, Locate}
@@ -64,7 +64,7 @@ object Defaults extends BuildCommon
concurrentRestrictions <<= concurrentRestrictions or defaultRestrictions,
parallelExecution :== true,
sbtVersion <<= appConfiguration { _.provider.id.version },
sbtBinaryVersion <<= sbtVersion apply binarySbtVersion,
sbtBinaryVersion <<= sbtVersion apply binarySbtVersionFuture,
sbtResolver <<= sbtVersion { sbtV => if(sbtV endsWith "-SNAPSHOT") Classpaths.typesafeSnapshots else Classpaths.typesafeReleases },
pollInterval :== 500,
logBuffered :== false,