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

chore: Aspect templating - 1/n #6799

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions aspect/get_java_provider.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def get_java_provider(target):
"""Find a provider exposing java compilation/outputs data."""

# Check for kt providers before JavaInfo. e.g. kt targets have
# JavaInfo, but their data lives in the "kt" provider and not JavaInfo.
# See https://github.com/bazelbuild/intellij/pull/1202
if hasattr(target, "kt") and hasattr(target.kt, "outputs"):
return target.kt
if JavaInfo in target:
return target[JavaInfo]
if hasattr(java_common, "JavaPluginInfo") and java_common.JavaPluginInfo in target:
return target[java_common.JavaPluginInfo]
return None
23 changes: 5 additions & 18 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
"""Implementation of IntelliJ-specific information collecting aspect."""

load(
"@bazel_tools//tools/build_defs/cc:action_names.bzl",
"ACTION_NAMES",
)
load(
":artifacts.bzl",
"artifact_location",
Expand All @@ -9,14 +13,11 @@ load(
"struct_omit_none",
"to_artifact_location",
)
load(":get_java_provider.bzl", "get_java_provider")
load(
":make_variables.bzl",
"expand_make_variables",
)
load(
"@bazel_tools//tools/build_defs/cc:action_names.bzl",
"ACTION_NAMES",
)

IntelliJInfo = provider(
doc = "Collected infromation about the targets visited by the aspect.",
Expand Down Expand Up @@ -586,20 +587,6 @@ def collect_c_toolchain_info(target, ctx, semantics, ide_info, ide_info_file, ou
update_sync_output_groups(output_groups, "intellij-info-cpp", depset([ide_info_file]))
return True

def get_java_provider(target):
"""Find a provider exposing java compilation/outputs data."""

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

def _collect_generated_files(java):
"""Collects generated files from a Java target"""
if hasattr(java, "java_outputs"):
Expand Down
Loading