Skip to content

Commit

Permalink
Update intellij plugin to use modern provider
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 587065404
  • Loading branch information
Googler authored and copybara-github committed Dec 1, 2023
1 parent 31a3800 commit 4bd9433
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions aspect/fast_build_info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def _fast_build_info_impl(target, ctx):
for t in annotation_processing.processor_classpath.to_list()
]
info["java_info"] = struct_omit_none(**java_info)
if hasattr(target, "android"):
if AndroidIdeInfo in target:
write_output = True
android_info = struct_omit_none(
aar = artifact_location(target.android.aar),
merged_manifest = artifact_location(target.android.merged_manifest),
aar = artifact_location(target[AndroidIdeInfo].aar),
merged_manifest = artifact_location(target[AndroidIdeInfo].generated_manifest),
)
info["android_info"] = android_info

Expand Down
23 changes: 15 additions & 8 deletions aspect/intellij_info_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -804,16 +804,23 @@ def collect_android_info(target, ctx, semantics, ide_info, ide_info_file, output

def _collect_android_ide_info(target, ctx, semantics, ide_info, ide_info_file, output_groups):
"""Updates ide_info proto with android_ide_info, and intellij_resolve_android with android resolve files. Returns false if target doesn't contain android attribute."""
if not hasattr(target, "android"):
if not AndroidIdeInfo in target:
return False

android_semantics = semantics.android if hasattr(semantics, "android") else None
extra_ide_info = android_semantics.extra_ide_info(target, ctx) if android_semantics else {}

android = target.android
android = target[AndroidIdeInfo]

output_jar = struct(
class_jar = android.idl_class_jar,
ijar = None,
source_jar = android.idl_source_jar,
) if android.idl_class_jar else None

resources = []
res_folders = []
resolve_files = jars_from_output(android.idl.output)
resolve_files = jars_from_output(output_jar)
if hasattr(ctx.rule.attr, "resource_files"):
for artifact_path_fragments, res_files in get_res_artifacts(ctx.rule.attr.resource_files).items():
# Generate unique ArtifactLocation for resource directories.
Expand Down Expand Up @@ -863,14 +870,14 @@ def _collect_android_ide_info(target, ctx, semantics, ide_info, ide_info_file, o

android_info = struct_omit_none(
java_package = android.java_package,
idl_import_root = android.idl.import_root if hasattr(android.idl, "import_root") else None,
idl_import_root = android.idl_import_root if hasattr(android, "idl_import_root") else None,
manifest = artifact_location(android.manifest),
manifest_values = [struct_omit_none(key = key, value = value) for key, value in ctx.rule.attr.manifest_values.items()] if hasattr(ctx.rule.attr, "manifest_values") else None,
apk = artifact_location(android.apk),
apk = artifact_location(android.signed_apk),
dependency_apk = [artifact_location(apk) for apk in android.apks_under_test],
has_idl_sources = android.idl.output != None,
idl_jar = library_artifact(android.idl.output),
generate_resource_class = android.defines_resources,
has_idl_sources = android.idl_class_jar != None,
idl_jar = library_artifact(output_jar),
generate_resource_class = android.defines_android_resources,
resources = resources,
res_folders = res_folders,
resource_jar = library_artifact(android.resource_jar),
Expand Down

0 comments on commit 4bd9433

Please sign in to comment.