mirror of https://github.com/sbt/sbt.git
Merge pull request #7568 from adpi2/fix-bsp-internal-dep-configs
[1.10.x] Fix declaring `Optional` inter-project dependency in BSP
This commit is contained in:
commit
586e0a752c
|
|
@ -13,7 +13,9 @@ import sbt.Keys._
|
|||
|
||||
private[sbt] object InternalDependencies {
|
||||
def configurations: Def.Initialize[Seq[(ProjectRef, Set[String])]] = Def.setting {
|
||||
val allConfigs = Classpaths.allConfigs(configuration.value).map(_.name).toSet
|
||||
val configMap = internalConfigurationMap.value
|
||||
val config = configMap(configuration.value)
|
||||
val allConfigs = Classpaths.allConfigs(config).map(_.name).toSet
|
||||
val ref = thisProjectRef.value
|
||||
val projectDependencies = buildDependencies.value.classpath.get(ref).toSeq.flatten
|
||||
val applicableConfigs = allConfigs + "*"
|
||||
|
|
|
|||
|
|
@ -23,31 +23,31 @@ def getConfigs(key: SettingKey[Seq[(ProjectRef, Set[String])]]):
|
|||
val checkA = taskKey[Unit]("Verify that project a's internal dependencies are as expected")
|
||||
checkA := {
|
||||
val compileDeps = getConfigs(a / Compile / internalDependencyConfigurations).value
|
||||
assert(compileDeps == Map("a" -> Set("compile")))
|
||||
assert(compileDeps == Map("a" -> Set("compile", "optional", "provided", "compile-internal")))
|
||||
val testDeps = getConfigs(a / Test / internalDependencyConfigurations).value
|
||||
assert(testDeps == Map("a" -> Set("compile", "runtime", "test")))
|
||||
assert(testDeps == Map("a" -> Set("compile", "optional", "provided", "runtime", "test", "test-internal")), testDeps.mkString(", "))
|
||||
}
|
||||
|
||||
val checkB = taskKey[Unit]("Verify that project b's internal dependencies are as expected")
|
||||
checkB := {
|
||||
val compileDeps = getConfigs(b / Compile / internalDependencyConfigurations).value
|
||||
assert(compileDeps == Map("b" -> Set("compile"), "a" -> Set("compile")))
|
||||
assert(compileDeps == Map("b" -> Set("compile", "optional", "provided", "compile-internal"), "a" -> Set("compile")))
|
||||
val testDeps = getConfigs(b / Test / internalDependencyConfigurations).value
|
||||
assert(testDeps == Map("b" -> Set("compile", "runtime", "test"), "a" -> Set("compile")))
|
||||
assert(testDeps == Map("b" -> Set("compile", "optional", "provided", "runtime", "test", "test-internal"), "a" -> Set("compile")))
|
||||
}
|
||||
|
||||
val checkC = taskKey[Unit]("Verify that project c's internal dependencies are as expected")
|
||||
checkC := {
|
||||
val compileDeps = getConfigs(c / Compile / internalDependencyConfigurations).value
|
||||
assert(compileDeps == Map("c" -> Set("compile")))
|
||||
assert(compileDeps == Map("c" -> Set("compile", "optional", "provided", "compile-internal")))
|
||||
val testDeps = getConfigs(c / Test / internalDependencyConfigurations).value
|
||||
assert(testDeps == Map("c" -> Set("compile", "runtime", "test")))
|
||||
assert(testDeps == Map("c" -> Set("compile", "optional", "provided", "runtime", "test", "test-internal")))
|
||||
}
|
||||
|
||||
val checkD = taskKey[Unit]("Verify that project d's internal dependencies are as expected")
|
||||
checkD := {
|
||||
val compileDeps = getConfigs(d / Compile / internalDependencyConfigurations).value
|
||||
assert(compileDeps == Map("d" -> Set("compile"), "c" -> Set("compile")))
|
||||
assert(compileDeps == Map("d" -> Set("compile", "optional", "provided", "compile-internal"), "c" -> Set("compile")))
|
||||
val testDeps = getConfigs(d / Test / internalDependencyConfigurations).value
|
||||
assert(testDeps == Map("d" -> Set("compile", "runtime", "test"), "c" -> Set("compile", "test")))
|
||||
assert(testDeps == Map("d" -> Set("compile", "optional", "provided", "runtime", "test", "test-internal"), "c" -> Set("compile", "test")))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ lazy val runAndTest = project.in(file("run-and-test"))
|
|||
Test / javaOptions := Vector("Xmx512M"),
|
||||
Test / envVars := Map("KEY_TEST" -> "VALUE_TEST"),
|
||||
)
|
||||
.dependsOn(util)
|
||||
.dependsOn(util % Optional)
|
||||
|
||||
lazy val reportError = project.in(file("report-error"))
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,12 @@ object BuildServerTest extends AbstractServerTest {
|
|||
test("workspace/buildTargets") { _ =>
|
||||
sendRequest("workspace/buildTargets")
|
||||
val result = svr.waitFor[WorkspaceBuildTargetsResult](10.seconds)
|
||||
val utilTarget = result.targets.find(_.displayName.contains("util")).get
|
||||
val utilTargetIdentifier = BuildTargetIdentifier(buildTargetUri("util", "Compile"))
|
||||
val utilTarget = result.targets.find(_.id == utilTargetIdentifier).get
|
||||
assert(utilTarget.id.uri.toString.endsWith("#util/Compile"))
|
||||
val runAndTestTarget = result.targets.find(_.displayName.contains("runAndTest")).get
|
||||
// runAndTest should declare the dependency to util even if optional
|
||||
assert(runAndTestTarget.dependencies.contains(utilTargetIdentifier))
|
||||
val buildServerBuildTarget =
|
||||
result.targets.find(_.displayName.contains("buildserver-build")).get
|
||||
assert(buildServerBuildTarget.id.uri.toString.endsWith("#buildserver-build"))
|
||||
|
|
@ -233,14 +237,19 @@ object BuildServerTest extends AbstractServerTest {
|
|||
}
|
||||
|
||||
test("buildTarget/scalacOptions, buildTarget/javacOptions") { _ =>
|
||||
val buildTarget = buildTargetUri("util", "Compile")
|
||||
val badBuildTarget = buildTargetUri("badBuildTarget", "Compile")
|
||||
val buildTargets = Seq(
|
||||
buildTargetUri("util", "Compile"),
|
||||
buildTargetUri("badBuildTarget", "Compile"),
|
||||
)
|
||||
|
||||
val id1 = scalacOptions(Seq(buildTarget, badBuildTarget))
|
||||
val id1 = scalacOptions(buildTargets)
|
||||
assertMessage(s""""id":"$id1"""", "scala-library-2.13.11.jar")()
|
||||
|
||||
val id2 = javacOptions(Seq(buildTarget, badBuildTarget))
|
||||
val id2 = javacOptions(buildTargets)
|
||||
assertMessage(s""""id":"$id2"""", "scala-library-2.13.11.jar")()
|
||||
|
||||
val id3 = scalacOptions(Seq(buildTargetUri("runAndTest", "Compile")))
|
||||
assertMessage(s""""id":"$id3"""", "util/target/scala-2.13/classes")()
|
||||
}
|
||||
|
||||
test("buildTarget/cleanCache") { _ =>
|
||||
|
|
|
|||
Loading…
Reference in New Issue