forked from scala/scala-dist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The windows version is used for the unix versions, so can't have its computation only run when running on windows.
- Loading branch information
Showing
4 changed files
with
52 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import sbt._ | ||
import sbt.Keys._ | ||
|
||
import com.typesafe.sbt.SbtNativePackager.{Windows, Debian, Rpm} | ||
|
||
object Versioning { | ||
def settings: Seq[Setting[_]] = Seq( | ||
version in Windows := makeWindowsVersion(version.value), | ||
version in Debian := toDebianVersion((version in Windows).value), | ||
version in Rpm := toRpmVersion((version in Windows).value)) | ||
|
||
private def rpmBuild(version:String): String = version split "\\." match { | ||
case Array(_,_,_, b) => b | ||
case _ => "1" | ||
} | ||
|
||
private def toRpmVersion(version:String): String = version split "\\." match { | ||
case Array(m,n,b,_*) => s"$m.$n.$b" | ||
case _ => version | ||
} | ||
|
||
private def toDebianVersion(version:String): String = version split "\\." match { | ||
case Array(m,n,b,z) => s"$m.$n.$b-$z" | ||
case _ => version | ||
} | ||
|
||
// This is a complicated means to convert maven version numbers into monotonically increasing windows versions. | ||
private def makeWindowsVersion(version: String): String = { | ||
val Majors = new scala.util.matching.Regex("(\\d+).(\\d+).(\\d+)(-.*)?") | ||
val Rcs = new scala.util.matching.Regex("(\\-\\d+)?\\-RC(\\d+)") | ||
val Milestones = new scala.util.matching.Regex("(\\-\\d+)?\\-M(\\d+)") | ||
val BuildNum = new scala.util.matching.Regex("\\-(\\d+)") | ||
|
||
def calculateNumberFour(buildNum: Int = 0, rc: Int = 0, milestone: Int = 0) = | ||
if(rc > 0 || milestone > 0) (buildNum)*400 + rc*20 + milestone | ||
else (buildNum+1)*400 + rc*20 + milestone | ||
|
||
version match { | ||
case Majors(major, minor, bugfix, rest) => Option(rest) getOrElse "" match { | ||
case Milestones(null, num) => major + "." + minor + "." + bugfix + "." + calculateNumberFour(0,0,num.toInt) | ||
case Milestones(bnum, num) => major + "." + minor + "." + bugfix + "." + calculateNumberFour(bnum.drop(1).toInt,0,num.toInt) | ||
case Rcs(null, num) => major + "." + minor + "." + bugfix + "." + calculateNumberFour(0,num.toInt,0) | ||
case Rcs(bnum, num) => major + "." + minor + "." + bugfix + "." + calculateNumberFour(bnum.drop(1).toInt,num.toInt,0) | ||
case BuildNum(bnum) => major + "." + minor + "." + bugfix + "." + calculateNumberFour(bnum.toInt,0,0) | ||
case _ => major + "." + minor + "." + bugfix + "." + calculateNumberFour(0,0,0) | ||
} | ||
case x => x | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters