diff --git a/ivy/CrossVersion.scala b/ivy/CrossVersion.scala index 59b51c795..e7c9a388c 100644 --- a/ivy/CrossVersion.scala +++ b/ivy/CrossVersion.scala @@ -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 diff --git a/main/Defaults.scala b/main/Defaults.scala index cc7adfecf..06e99fc14 100755 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -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,