mirror of https://github.com/sbt/sbt.git
Fix parsing of dependencies config mapping of Ivy files
This commit is contained in:
parent
2e6e061fe1
commit
357c3fa0f7
|
|
@ -28,6 +28,20 @@ object IvyXml {
|
||||||
name -> node.attribute("extends").toOption.toSeq.flatMap(_.split(','))
|
name -> node.attribute("extends").toOption.toSeq.flatMap(_.split(','))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME "default(compile)" likely not to be always the default
|
||||||
|
def mappings(mapping: String): Seq[(String, String)] =
|
||||||
|
mapping.split(';').flatMap { m =>
|
||||||
|
val (froms, tos) = m.split("->", 2) match {
|
||||||
|
case Array(from) => (from, "default(compile)")
|
||||||
|
case Array(from, to) => (from, to)
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
from <- froms.split(',')
|
||||||
|
to <- tos.split(',')
|
||||||
|
} yield (from.trim, to.trim)
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME Errors ignored as above - warnings should be reported at least for anything suspicious
|
// FIXME Errors ignored as above - warnings should be reported at least for anything suspicious
|
||||||
private def dependencies(node: Node): Seq[(String, Dependency)] =
|
private def dependencies(node: Node): Seq[(String, Dependency)] =
|
||||||
node.children
|
node.children
|
||||||
|
|
@ -53,9 +67,7 @@ object IvyXml {
|
||||||
name <- node.attribute("name").toOption.toSeq
|
name <- node.attribute("name").toOption.toSeq
|
||||||
version <- node.attribute("rev").toOption.toSeq
|
version <- node.attribute("rev").toOption.toSeq
|
||||||
rawConf <- node.attribute("conf").toOption.toSeq
|
rawConf <- node.attribute("conf").toOption.toSeq
|
||||||
(fromConf, toConf) <- rawConf.split(',').toSeq.map(_.split("->", 2)).collect {
|
(fromConf, toConf) <- mappings(rawConf)
|
||||||
case Array(from, to) => from -> to
|
|
||||||
}
|
|
||||||
attr = node.attributesFromNamespace(attributesNamespace)
|
attr = node.attributesFromNamespace(attributesNamespace)
|
||||||
} yield fromConf -> Dependency(
|
} yield fromConf -> Dependency(
|
||||||
Module(org, name, attr.toMap),
|
Module(org, name, attr.toMap),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package coursier
|
package coursier
|
||||||
|
|
||||||
import coursier.ivy.IvyRepository
|
import coursier.ivy.{ IvyXml, IvyRepository }
|
||||||
import sbt.mavenint.SbtPomExtraProperties
|
import sbt.mavenint.SbtPomExtraProperties
|
||||||
import sbt.{ Resolver, CrossVersion, ModuleID }
|
import sbt.{ Resolver, CrossVersion, ModuleID }
|
||||||
|
|
||||||
|
|
@ -24,19 +24,6 @@ object FromSbt {
|
||||||
case f: CrossVersion.Binary => name + "_" + f.remapVersion(scalaBinaryVersion)
|
case f: CrossVersion.Binary => name + "_" + f.remapVersion(scalaBinaryVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
def mappings(mapping: String): Seq[(String, String)] =
|
|
||||||
mapping.split(';').flatMap { m =>
|
|
||||||
val (froms, tos) = m.split("->", 2) match {
|
|
||||||
case Array(from) => (from, "default(compile)")
|
|
||||||
case Array(from, to) => (from, to)
|
|
||||||
}
|
|
||||||
|
|
||||||
for {
|
|
||||||
from <- froms.split(',')
|
|
||||||
to <- tos.split(',')
|
|
||||||
} yield (from.trim, to.trim)
|
|
||||||
}
|
|
||||||
|
|
||||||
def attributes(attr: Map[String, String]): Map[String, String] =
|
def attributes(attr: Map[String, String]): Map[String, String] =
|
||||||
attr.map { case (k, v) =>
|
attr.map { case (k, v) =>
|
||||||
k.stripPrefix("e:") -> v
|
k.stripPrefix("e:") -> v
|
||||||
|
|
@ -64,7 +51,7 @@ object FromSbt {
|
||||||
)
|
)
|
||||||
|
|
||||||
val mapping = module.configurations.getOrElse("compile")
|
val mapping = module.configurations.getOrElse("compile")
|
||||||
val allMappings = mappings(mapping)
|
val allMappings = IvyXml.mappings(mapping)
|
||||||
|
|
||||||
val attributes =
|
val attributes =
|
||||||
if (module.explicitArtifacts.isEmpty)
|
if (module.explicitArtifacts.isEmpty)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue