Playã®ãã¼ã¸ã§ã³ãæ¯è¼ãããã¤æ¸ãããã
Play ã¯ããã¸ã§ã¯ãã®ãã¼ã¸ã§ã³ã¨ä½¿ç¨ãã¦ãã Play ã³ãã³ãã®ãã¼ã¸ã§ã³ãé£ãéã£ã¦ããã¨è¦åãåºããã§ããããã¼ã¸ã§ã³ã®æ¯è¼ãåããã©ããããè¦ã¦ããªãã®ã«ã¨ã©ã¼ã¡ãã»ã¼ã¸ã Update ããã¨ããããã¤ãªã®ã§
https://github.com/playframework/Play20/blob/2.1.1/framework/src/sbt-plugin/src/main/scala/play/Project.scala#L23
Option(System.getProperty("play.version")).map { case badVersion if badVersion != play.core.PlayVersion.current => { println( Colors.red(""" |This project uses Play %s! |Update the Play sbt-plugin version to %s (usually in project/plugins.sbt) """.stripMargin.format(play.core.PlayVersion.current, badVersion)) ) } case _ => }
ãããã風ã«ããï¼ãªã¨ã©ã¼ã¡ãã»ã¼ã¸ã«ãªããã¨ãããã¾ãã
ã§ãæ°æã¡æªãã®ã§ç´ããã¨æã£ã¦ãã¼ã¸ã§ã³ãæ¯è¼ããã®ãæ¸ãããã§ããã
ããèãããã¨ã©ã¼ã¡ãã»ã¼ã¸ãã¡ãã£ã¨ç´ãã°ããã ããããããã®ã³ã¼ãå
¨ç¶ãããã¼ï¼ãã¼ã¸ã§ã³ãã¼ã¹ããã®ã«ãã¼ãµã³ã³ããã¼ã¿ã¨ãæã¡åºãã¦èªåã°ã£ããããã¼ã®ã£ã¦ãã¨ã«æ°ã¥ãã¾ãããããã°ã©ã æ¸ãåã«å¿
è¦ãã©ããã¡ããã¨èãããã£ã¦è©±ã§ããã
ãã£ããæ¸ããã®ã§è²¼ã£ã¦ããã¾ããããã
ããããã°ãOrdering ã¯ã¢ãã¤ãã ããããã¬ãã£ã¦è©±ãããã¾ãããã©ãScalaz ã§ã¯ãªã Scala ã®å ´åã¯ã¾ã Ordering.by 㧠Tuple ã®æ¯è¼ã¨ãã«è½ã¨ãã®ãã·ã³ãã«ã§ããã®ããªã¨æãã¾ããã
import scala.util.parsing.combinator._ class PlayVersionException(val message: String) extends Exception(message) sealed abstract class VersionMilestone(val value: Int) case object Alpha extends VersionMilestone(0) case object Beta extends VersionMilestone(1) case class RC(number: Int) extends VersionMilestone(2) case object Regular extends VersionMilestone(3) case class PlayVersion(major: Int, middle: Int, minor: Int, versionMilestone: VersionMilestone) { def >(x: PlayVersion)(implicit ord: Ordering[PlayVersion]): Boolean = { if (implicitly[Ordering[PlayVersion]].lteq(this, x)) false else true } def <(x: PlayVersion)(implicit ord: Ordering[PlayVersion]): Boolean = { ! this.>(x)(ord) } } object PlayVersionParser extends RegexParsers { def number = """[0-9]+""".r def major = number ^^ { _.toInt } def middle = number ^^ { _.toInt } def minor = number ^^ { _.toInt } def rc: Parser[VersionMilestone] = "-RC" ~> number ^^ { n => RC(n.toInt) } def beta: Parser[VersionMilestone] = "-beta" ^^ { _ => Beta } def alpha: Parser[VersionMilestone] = "-alpha" ^^ { _ => Alpha } def earlyVersion: Parser[VersionMilestone] = rc | beta | alpha def version: Parser[PlayVersion] = major ~ ("." ~> middle) ~ opt("." ~> minor) ~ opt(earlyVersion) ^^ { case major ~ middle ~ minor ~ earlyVersion => PlayVersion(major, middle, minor.getOrElse(0), earlyVersion.getOrElse(Regular)) } def parse(in: String): PlayVersion = parseAll(version, in) match { case Success(result, _) => result case failure : NoSuccess => throw new PlayVersionException("Unexpected version naming convention.") } } implicit val versionMilestoneOrdering = new Ordering[VersionMilestone] { def compare(x: VersionMilestone, y: VersionMilestone): Int = { (x, y) match { case (x, y) if x == y => 0 case (RC(i), RC(j)) => i - j case (x, y) => x.value - y.value } } } implicit val playVersionOrdering: Ordering[PlayVersion] = { Ordering.by[PlayVersion, (Int, Int, Int, VersionMilestone)] { v: PlayVersion => (v.major, v.middle, v.minor, v.versionMilestone) } } object PlayVersion { def apply(versionString: String): PlayVersion = { PlayVersionParser.parse(versionString) } } assert(PlayVersion("2.1.1") > PlayVersion("2.0")) assert(PlayVersion("2.1.1") > PlayVersion("2.1.0")) assert(PlayVersion("2.1.1") > PlayVersion("2.1.1-RC1")) assert(PlayVersion("2.1.1-RC1") == PlayVersion("2.1.1-RC1")) assert(PlayVersion("2.1.1-RC2") > PlayVersion("2.1.1-RC1")) assert(PlayVersion("2.1.1-RC2") > PlayVersion("2.1.1-beta")) assert(PlayVersion("2.1.1-alpha") < PlayVersion("2.1.1-beta"))