mirror of https://github.com/sbt/sbt.git
Add support for intransitive dependencies
This commit is contained in:
parent
997e3f4a80
commit
3fd060a75a
|
|
@ -44,7 +44,9 @@ case class Dependency(
|
|||
|
||||
// Maven-specific
|
||||
attributes: Attributes,
|
||||
optional: Boolean
|
||||
optional: Boolean,
|
||||
|
||||
transitive: Boolean
|
||||
) {
|
||||
def moduleVersion = (module, version)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -434,14 +434,17 @@ case class Resolution(
|
|||
new mutable.HashMap[Dependency, Seq[Dependency]]()
|
||||
private def finalDependencies0(dep: Dependency) =
|
||||
finalDependenciesCache.synchronized {
|
||||
finalDependenciesCache.getOrElseUpdate(dep,
|
||||
projectCache.get(dep.moduleVersion) match {
|
||||
case Some((_, proj)) =>
|
||||
finalDependencies(dep, proj)
|
||||
.filter(filter getOrElse defaultFilter)
|
||||
case None => Nil
|
||||
}
|
||||
)
|
||||
finalDependenciesCache.getOrElseUpdate(dep, {
|
||||
if (dep.transitive)
|
||||
projectCache.get(dep.moduleVersion) match {
|
||||
case Some((_, proj)) =>
|
||||
finalDependencies(dep, proj)
|
||||
.filter(filter getOrElse defaultFilter)
|
||||
case None => Nil
|
||||
}
|
||||
else
|
||||
Nil
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -69,14 +69,22 @@ object IvyXml {
|
|||
rawConf <- node.attribute("conf").toOption.toSeq
|
||||
(fromConf, toConf) <- mappings(rawConf)
|
||||
attr = node.attributesFromNamespace(attributesNamespace)
|
||||
} yield fromConf -> Dependency(
|
||||
Module(org, name, attr.toMap),
|
||||
version,
|
||||
toConf,
|
||||
allConfsExcludes ++ excludes.getOrElse(fromConf, Set.empty),
|
||||
Attributes("jar", ""), // should come from possible artifact nodes
|
||||
optional = false
|
||||
)
|
||||
} yield {
|
||||
val transitive = node.attribute("transitive").toOption match {
|
||||
case Some("false") => false
|
||||
case _ => true
|
||||
}
|
||||
|
||||
fromConf -> Dependency(
|
||||
Module(org, name, attr.toMap),
|
||||
version,
|
||||
toConf,
|
||||
allConfsExcludes ++ excludes.getOrElse(fromConf, Set.empty),
|
||||
Attributes("jar", ""), // should come from possible artifact nodes
|
||||
optional = false,
|
||||
transitive = transitive
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private def publications(node: Node): Map[String, Seq[Publication]] =
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ object Pom {
|
|||
"",
|
||||
exclusions.map(mod => (mod.organization, mod.name)).toSet,
|
||||
Attributes(typeOpt getOrElse defaultType, classifierOpt getOrElse defaultClassifier),
|
||||
optional
|
||||
optional,
|
||||
transitive = true
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,8 @@ package object coursier {
|
|||
configuration: String = "",
|
||||
attributes: Attributes = Attributes(),
|
||||
exclusions: Set[(String, String)] = Set.empty,
|
||||
optional: Boolean = false
|
||||
optional: Boolean = false,
|
||||
transitive: Boolean = true
|
||||
): Dependency =
|
||||
core.Dependency(
|
||||
module,
|
||||
|
|
@ -21,7 +22,8 @@ package object coursier {
|
|||
configuration,
|
||||
exclusions,
|
||||
attributes,
|
||||
optional
|
||||
optional,
|
||||
transitive
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@ object FromSbt {
|
|||
exclusions = module.exclusions.map { rule =>
|
||||
// FIXME Other `rule` fields are ignored here
|
||||
(rule.organization, rule.name)
|
||||
}.toSet
|
||||
}.toSet,
|
||||
transitive = module.isTransitive
|
||||
)
|
||||
|
||||
val mapping = module.configurations.getOrElse("compile")
|
||||
|
|
|
|||
Loading…
Reference in New Issue