mirror of https://github.com/sbt/sbt.git
Merge pull request #6414 from adpi2/fix-6410
Fix internal dependency configurations
This commit is contained in:
commit
3e125fa040
|
|
@ -14,19 +14,21 @@ private[sbt] object InternalDependencies {
|
|||
def configurations: Def.Initialize[Seq[(ProjectRef, Set[String])]] = Def.setting {
|
||||
val allConfigs = Classpaths.allConfigs(configuration.value).map(_.name).toSet
|
||||
val ref = thisProjectRef.value
|
||||
val projectDependencies = buildDependencies.value.classpath.get(ref).toSeq.flatten
|
||||
val applicableConfigs = allConfigs + "*"
|
||||
((ref -> allConfigs) +: buildDependencies.value.classpath
|
||||
.get(ref)
|
||||
.toSeq
|
||||
.flatMap(_.flatMap {
|
||||
((ref -> allConfigs) +:
|
||||
projectDependencies.flatMap {
|
||||
case ResolvedClasspathDependency(p, rawConfigs) =>
|
||||
val configs = rawConfigs.getOrElse("*->compile").split(";").flatMap { config =>
|
||||
config.split("->") match {
|
||||
case Array(n, c) if applicableConfigs.contains(n) => Some(c)
|
||||
case _ => None
|
||||
case Array(n) if applicableConfigs.contains(n) =>
|
||||
// "test" is equivalent to "compile->test"
|
||||
Some("compile")
|
||||
case _ => None
|
||||
}
|
||||
}
|
||||
if (configs.isEmpty) None else Some(p -> configs.toSet)
|
||||
})).distinct
|
||||
}).distinct
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
lazy val a = project.in(file("a")).dependsOn(b % Test)
|
||||
|
||||
lazy val b = project.in(file("b")).dependsOn(c)
|
||||
|
||||
lazy val c = project.in(file("c"))
|
||||
|
||||
def getConfigs(key: SettingKey[Seq[(ProjectRef, Set[ConfigKey])]]):
|
||||
Def.Initialize[Map[String, Set[String]]] =
|
||||
Def.setting(key.value.map { case (p, c) => p.project -> c.map(_.name) }.toMap)
|
||||
|
||||
TaskKey[Unit]("check") := {
|
||||
val testDeps = getConfigs(a / Test / bspInternalDependencyConfigurations).value
|
||||
val expected = Map(
|
||||
"a" -> Set("compile", "test"),
|
||||
"b" -> Set("compile"),
|
||||
"c" -> Set("compile")
|
||||
)
|
||||
assert(testDeps == expected)
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
> check
|
||||
Loading…
Reference in New Issue