Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.10.x] Fix declaring Optional inter-project dependency in BSP #7568

Merged
merged 2 commits into from
May 23, 2024

Conversation

adpi2
Copy link
Member

@adpi2 adpi2 commented May 21, 2024

val a = project.in(file("a"))

val b = project.in(file("b")).dependsOn(a % Optional)

In BSP there is no notion of Optional or Provided dependencies. But the b#Compile build target should contain a dependency to a#Compile because it needs it to compile. (The classphath configuration is CompileInternal which extends Optional and Provided).

To fix this we use the internalConfigurationMap to compute the internal dependencies of a configuration.

@unkarjedy This PR should fix https://youtrack.jetbrains.com/issue/SCL-22476/SBTBSP-build-with-an-optional-inter-project-dependency-results-in-cannot-resolve-symbol-errors

Comment on lines 14 to +18
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used by BSP and by watch. Which means that modifying a will trigger the watch of ~b/compile which seems correct since a is in the compilation classpath of b.

@adpi2 adpi2 marked this pull request as ready for review May 22, 2024 08:54
@adpi2 adpi2 requested a review from eed3si9n May 22, 2024 08:54
@adpi2 adpi2 merged commit 586e0a7 into sbt:1.10.x May 23, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants