-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure Bloop runs on JVM that satisfies requirements
(rebase onto master)
- Loading branch information
1 parent
d54e6b8
commit 474572f
Showing
22 changed files
with
324 additions
and
156 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
24 changes: 24 additions & 0 deletions
24
modules/bloop-rifle/src/main/scala/scala/build/bloop/VersionOps.scala
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,24 @@ | ||
package scala.build.bloop | ||
|
||
object VersionOps { | ||
implicit class VersionOps_(lhs: String) { | ||
def toInt(s: String): Option[Int] = | ||
try Some(Integer.parseInt(s)) | ||
catch { | ||
case _: NumberFormatException => None | ||
} | ||
|
||
def isNewerThan(rhs: String): Boolean = { | ||
def lhsInt: Int => Option[Int] = lhs.split("[-.]").map(toInt).map(_.getOrElse(-1)).toList.lift | ||
def rhsInt: Int => Option[Int] = rhs.split("[-.]").map(toInt).map(_.getOrElse(-1)).toList.lift | ||
(0 until Int.MaxValue) | ||
.takeWhile(i => rhsInt(i).isDefined || lhsInt(i).isDefined) | ||
.map(i => (lhsInt(i), rhsInt(i))) | ||
.find { case (l, r) => (l != r) } | ||
.map { case (l, r) => l.getOrElse(-1) > r.getOrElse(-1) } | ||
.getOrElse(false) | ||
} | ||
} | ||
|
||
def maxVersion(lhs: String, rhs: String) = if (lhs isNewerThan rhs) lhs else rhs | ||
} |
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
Oops, something went wrong.