Skip to content

Commit

Permalink
Prioritzie scala and kt providers before JavaInfo (bazelbuild/intelli…
Browse files Browse the repository at this point in the history
…j PR import #1202)

While `scala_library` / other Scala rules have `JavaInfo` as well, their Scala-specific data lives in the `scala` provider. Proritizing `JavaInfo` over `scala` causes the plugin to assume that there are no outputs, hence causing all Scala workspaces to fail to resolve ("No Scala SDK added") #1183

Instead, prioritize `kt` and `scala` providers over `JavaInfo`.

This wasn't an issue previously because we c[hecked for the legacy "java" provider first](5f03bde), which Scala targets do not have, and the conditional successfully fell through.

This fixes #1183.

Closes #1202

PiperOrigin-RevId: 271236868
  • Loading branch information
jin authored and copybara-github committed Sep 25, 2019
1 parent 7dc11c6 commit b343686
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,16 @@ def collect_c_toolchain_info(target, ctx, semantics, ide_info, ide_info_file, ou

def get_java_provider(target):
"""Find a provider exposing java compilation/outputs data."""
if JavaInfo in target:
return target[JavaInfo]

# Check for scala and kt providers before JavaInfo. e.g. scala targets have
# JavaInfo, but their data lives in the "scala" provider and not JavaInfo.
# See https://github.com/bazelbuild/intellij/pull/1202
if hasattr(target, "scala"):
return target.scala
if hasattr(target, "kt") and hasattr(target.kt, "outputs"):
return target.kt
if JavaInfo in target:
return target[JavaInfo]
return None

def collect_java_info(target, ctx, semantics, ide_info, ide_info_file, output_groups):
Expand Down

0 comments on commit b343686

Please sign in to comment.