Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

scala library doesn't show up in intellij #246

Open
joprice opened this issue Nov 27, 2019 · 5 comments
Open

scala library doesn't show up in intellij #246

joprice opened this issue Nov 27, 2019 · 5 comments

Comments

@joprice
Copy link
Contributor

joprice commented Nov 27, 2019

I was not able to get intellij to recognize my scala library version until I added the scala library to the runtime_deps of the scala_library (adding it to deps caused buildozer to request removing it):

scala_library(
  runtime_deps = [
    "@maven//:org_scala_lang_scala_library",
  ],
  ...
)

Not sure whether this is expected, or if an issue with how the rules are defined or something with my setup.

@SrodriguezO
Copy link
Collaborator

Hey @joprice you shouldn't have to include the Scala standard library as a dependency. How are you binding default_scala in your WORKSPACE?

Also, what version of the IntelliJ plugin are you using?

@joprice
Copy link
Contributor Author

joprice commented Nov 28, 2019

I am using Intelij 2019.2.4 and Bazel plugin 2019.11.14.0.1. I'm configuring it like this:

bind(
    name = "default_scala",
    actual = "@rules_scala_annex//src/main/scala:zinc_2_12_8",
)

@SrodriguezO
Copy link
Collaborator

SrodriguezO commented Dec 9, 2019

I've seen this issue when a custom ScalaConfiguration doesn't include the Scala compiler in its compiler_classpath, but the default one does so that's not it..

It might be that the IntelliJ plugin doesn't recognize it if it's coming from an external source. If that's the case, then specifying your own ScalaConfiguration in your workspace as explained here might be the way to go (although that'd be unfortunate because it'd mean the experience when using the default isn't great :/) simpler workaround in next comment

@SrodriguezO
Copy link
Collaborator

I poked around a bit more. This is an odd bug. If @annex//:org_scala_lang_scala_library or @annex//:org_scala_lang_scala_compiler are included as deps or runtime_deps on any Scala target in your workspace, IntelliJ recognizes things correctly everywhere, even if that target's not used.

Specifying your own ScalaConfiguration would make the issue go away because it specifies a scala_library with these deps, but a simpler work around would be to add a dummy rule somewhere.

e.g.

scala_binary(
    name = "fooNotUsed",
    runtime_deps = ["@annex//:org_scala_lang_scala_library"],
)

@joprice
Copy link
Contributor Author

joprice commented Jan 2, 2020

I'm also having this issue when using multiple scala versions, and the workaround doesn't seem to help. I have some projects on 2.12 and others on 2.11. Both projects seem to think they have some scala version available, as I can jump to source, but there is always a banner up top saying "No Scala SDK in module". When clicking Setup Scala SDK, it offers an incorrect version from the local ivy cache. For scala 2.12 projects, newer features like Future.unit are red since it's validating against an older version of scala. I would expect in the latter case for it to be broken as before, but it looks like it's using some global version.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants