mirror of https://github.com/sbt/sbt.git
Merge branch '0.13' into 0.13.6
This commit is contained in:
commit
7e0c76f5a6
|
|
@ -196,6 +196,7 @@ class MakePom(val log: Logger) {
|
||||||
</dependency>
|
</dependency>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Converts Ivy revision ranges to that of Maven POM */
|
||||||
def makeDependencyVersion(revision: String): String = {
|
def makeDependencyVersion(revision: String): String = {
|
||||||
def plusRange(s: String, shift: Int = 0) = {
|
def plusRange(s: String, shift: Int = 0) = {
|
||||||
def pow(i: Int): Int = if (i > 0) 10 * pow(i - 1) else 1
|
def pow(i: Int): Int = if (i > 0) 10 * pow(i - 1) else 1
|
||||||
|
|
@ -209,20 +210,26 @@ class MakePom(val log: Logger) {
|
||||||
}
|
}
|
||||||
val startSym = Set(']', '[', '(')
|
val startSym = Set(']', '[', '(')
|
||||||
val stopSym = Set(']', '[', ')')
|
val stopSym = Set(']', '[', ')')
|
||||||
|
val DotPlusPattern = """(.+)\.\+""".r
|
||||||
|
val DotNumPlusPattern = """(.+)\.(\d+)\+""".r
|
||||||
|
val NumPlusPattern = """(\d+)\+""".r
|
||||||
|
val maxDigit = 5
|
||||||
try {
|
try {
|
||||||
if (revision endsWith ".+") {
|
revision match {
|
||||||
plusRange(revision.substring(0, revision.length - 2))
|
case "+" => "[0,)"
|
||||||
} else if (revision endsWith "+") {
|
case DotPlusPattern(base) => plusRange(base)
|
||||||
val base = revision.take(revision.length - 1)
|
|
||||||
// This is a heuristic. Maven just doesn't support Ivy's notions of 1+, so
|
// This is a heuristic. Maven just doesn't support Ivy's notions of 1+, so
|
||||||
// we assume version ranges never go beyond 5 siginificant digits.
|
// we assume version ranges never go beyond 5 siginificant digits.
|
||||||
(0 to 5).map(plusRange(base, _)).mkString(",")
|
case NumPlusPattern(tail) => (0 until maxDigit).map(plusRange(tail, _)).mkString(",")
|
||||||
} else if (startSym(revision(0)) && stopSym(revision(revision.length - 1))) {
|
case DotNumPlusPattern(base, tail) => (0 until maxDigit).map(plusRange(base + "." + tail, _)).mkString(",")
|
||||||
val start = revision(0)
|
case rev if rev endsWith "+" => sys.error(s"dynamic revision '$rev' cannot be translated to POM")
|
||||||
val stop = revision(revision.length - 1)
|
case rev if startSym(rev(0)) && stopSym(rev(rev.length - 1)) =>
|
||||||
val mid = revision.substring(1, revision.length - 1)
|
val start = rev(0)
|
||||||
|
val stop = rev(rev.length - 1)
|
||||||
|
val mid = rev.substring(1, rev.length - 1)
|
||||||
(if (start == ']') "(" else start) + mid + (if (stop == '[') ")" else stop)
|
(if (start == ']') "(" else start) + mid + (if (stop == '[') ")" else stop)
|
||||||
} else revision
|
case _ => revision
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
case e: NumberFormatException =>
|
case e: NumberFormatException =>
|
||||||
// TODO - if the version doesn't meet our expectations, maybe we just issue a hard
|
// TODO - if the version doesn't meet our expectations, maybe we just issue a hard
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package sbt
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import org.specs2._
|
||||||
|
|
||||||
|
// http://ant.apache.org/ivy/history/2.3.0/ivyfile/dependency.html
|
||||||
|
// http://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
|
||||||
|
class MakePomSpec extends Specification {
|
||||||
|
def is = s2"""
|
||||||
|
|
||||||
|
This is a specification to check the Ivy revision number conversion to pom.
|
||||||
|
|
||||||
|
1.0 should
|
||||||
|
${convertTo("1.0", "1.0")}
|
||||||
|
|
||||||
|
[1.0,2.0] should
|
||||||
|
${convertTo("[1.0,2.0]", "[1.0,2.0]")}
|
||||||
|
|
||||||
|
[1.0,2.0[ should
|
||||||
|
${convertTo("[1.0,2.0[", "[1.0,2.0)")}
|
||||||
|
|
||||||
|
]1.0,2.0] should
|
||||||
|
${convertTo("]1.0,2.0]", "(1.0,2.0]")}
|
||||||
|
|
||||||
|
]1.0,2.0[ should
|
||||||
|
${convertTo("]1.0,2.0[", "(1.0,2.0)")}
|
||||||
|
|
||||||
|
[1.0,) should
|
||||||
|
${convertTo("[1.0,)", "[1.0,)")}
|
||||||
|
|
||||||
|
]1.0,) should
|
||||||
|
${convertTo("]1.0,)", "(1.0,)")}
|
||||||
|
|
||||||
|
(,2.0] should
|
||||||
|
${convertTo("(,2.0]", "(,2.0]")}
|
||||||
|
|
||||||
|
(,2.0[ should
|
||||||
|
${convertTo("(,2.0[", "(,2.0)")}
|
||||||
|
|
||||||
|
1.+ should
|
||||||
|
${convertTo("1.+", "[1,2)")}
|
||||||
|
|
||||||
|
1.2.3.4.+ should
|
||||||
|
${convertTo("1.2.3.4.+", "[1.2.3.4,1.2.3.5)")}
|
||||||
|
|
||||||
|
12.31.42.+ should
|
||||||
|
${convertTo("12.31.42.+", "[12.31.42,12.31.43)")}
|
||||||
|
|
||||||
|
1.1+ should
|
||||||
|
${convertTo("1.1+", "[1.1,1.2),[1.10,1.20),[1.100,1.200),[1.1000,1.2000),[1.10000,1.20000)")}
|
||||||
|
|
||||||
|
1+ should
|
||||||
|
${convertTo("1+", "[1,2),[10,20),[100,200),[1000,2000),[10000,20000)")}
|
||||||
|
|
||||||
|
+ should
|
||||||
|
${convertTo("+", "[0,)")}
|
||||||
|
|
||||||
|
foo+ should
|
||||||
|
${beParsedAsError("foo+")}
|
||||||
|
"""
|
||||||
|
|
||||||
|
val mp = new MakePom(ConsoleLogger())
|
||||||
|
def convertTo(s: String, expected: String) =
|
||||||
|
mp.makeDependencyVersion(s) must_== expected
|
||||||
|
def beParsedAsError(s: String) =
|
||||||
|
try {
|
||||||
|
mp.makeDependencyVersion(s)
|
||||||
|
failure
|
||||||
|
} catch {
|
||||||
|
case e: Throwable => success
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
package sbt
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import org.specs2._
|
|
||||||
import mutable.Specification
|
|
||||||
|
|
||||||
object MakePomTest extends Specification {
|
|
||||||
val mp = new MakePom(ConsoleLogger())
|
|
||||||
import mp.{ makeDependencyVersion => v }
|
|
||||||
"MakePom makeDependencyVersion" should {
|
|
||||||
"Handle .+ in versions" in {
|
|
||||||
v("1.+") must_== "[1,2)"
|
|
||||||
v("1.2.3.4.+") must_== "[1.2.3.4,1.2.3.5)"
|
|
||||||
v("12.31.42.+") must_== "[12.31.42,12.31.43)"
|
|
||||||
}
|
|
||||||
/* TODO - do we care about this case?
|
|
||||||
* 1+ --> [1,2),[10,20),[100,200),[1000,2000),[10000,20000),[100000,200000)
|
|
||||||
*/
|
|
||||||
"Handle ]* bracket in version ranges" in {
|
|
||||||
v("]1,3]") must_== "(1,3]"
|
|
||||||
v("]1.1,1.3]") must_== "(1.1,1.3]"
|
|
||||||
}
|
|
||||||
"Handle *[ bracket in version ranges" in {
|
|
||||||
v("[1,3[") must_== "[1,3)"
|
|
||||||
v("[1.1,1.3[") must_== "[1.1,1.3)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
[1194]: https://github.com/sbt/sbt/issues/1194
|
[1194]: https://github.com/sbt/sbt/issues/1194
|
||||||
[1200]: https://github.com/sbt/sbt/issues/1200
|
[1200]: https://github.com/sbt/sbt/issues/1200
|
||||||
[1213]: https://github.com/sbt/sbt/issues/1213
|
[1213]: https://github.com/sbt/sbt/issues/1213
|
||||||
|
[1275]: https://github.com/sbt/sbt/issues/1275
|
||||||
[1312]: https://github.com/sbt/sbt/pull/1312
|
[1312]: https://github.com/sbt/sbt/pull/1312
|
||||||
[1313]: https://github.com/sbt/sbt/pull/1313
|
[1313]: https://github.com/sbt/sbt/pull/1313
|
||||||
[1315]: https://github.com/sbt/sbt/issues/1315
|
[1315]: https://github.com/sbt/sbt/issues/1315
|
||||||
|
|
@ -119,6 +120,7 @@
|
||||||
- Fixes `http.proxyPassword` showing up in launcher's update.log. [#670][670] by [@eed3si9n][@eed3si9n]
|
- Fixes `http.proxyPassword` showing up in launcher's update.log. [#670][670] by [@eed3si9n][@eed3si9n]
|
||||||
- Fixes config-classes leak in loading build files. [#1524][1524] by [@jsuereth][@jsuereth]
|
- Fixes config-classes leak in loading build files. [#1524][1524] by [@jsuereth][@jsuereth]
|
||||||
- Fixes name-conflicts in hashed settings class files. [#1465][1465] by [@jsuereth][@jsuereth]
|
- Fixes name-conflicts in hashed settings class files. [#1465][1465] by [@jsuereth][@jsuereth]
|
||||||
|
- Fixes the pom conversion of dynamic revisions like `1.1+`. [#1275][1275] by [@eed3si9n][@eed3si9n]
|
||||||
- Fixes `NullPointerError` in tab completion by `FileExamples`. [#1530][1530] by [@eed3si9n][@eed3si9n]
|
- Fixes `NullPointerError` in tab completion by `FileExamples`. [#1530][1530] by [@eed3si9n][@eed3si9n]
|
||||||
- Fixes metabuild downloading unused Scala 2.10.2. [#1439][1439] by [@eed3si9n][@eed3si9n]
|
- Fixes metabuild downloading unused Scala 2.10.2. [#1439][1439] by [@eed3si9n][@eed3si9n]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue