mirror of
https://github.com/sbt/sbt.git
synced 2026-10-06 10:03:56 +02:00
Make sbtBinaryVersion use the new approach for 0.13 and later to support cross-building plugins.
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user