Skip to content

Commit

Permalink
Expose kotlin provider in android libraries
Browse files Browse the repository at this point in the history
Summary: The bazel IDE plugin needs to read data from the kotlin provider, in the new android starlark rules it was missing from the final struct for android libraries.

Test Plan: TBD

Revert Plan: Revert diff

Differential Revision: https://code.uberinternal.com/D13499789
  • Loading branch information
idanakav authored and jbarr21 committed Apr 19, 2024
1 parent 1e919c2 commit 12dc10d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion kotlin/internal/jvm/kt_android_library_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ load(
)
load("@rules_android//rules:java.bzl", _java = "java")
load("@rules_android//rules:processing_pipeline.bzl", _ProviderInfo = "ProviderInfo", _processing_pipeline = "processing_pipeline")
load("@rules_android//rules/android_library:impl.bzl", _BASE_PROCESSORS = "PROCESSORS", _finalize = "finalize")
load("@rules_android//rules/android_library:impl.bzl", _BASE_PROCESSORS = "PROCESSORS", _android_library_finalize = "finalize")
load("@rules_android//rules:utils.bzl", _get_android_sdk = "get_android_sdk", _utils = "utils")

def _process_jvm(ctx, resources_ctx, **unused_sub_ctxs):
Expand All @@ -39,13 +39,27 @@ def _process_jvm(ctx, resources_ctx, **unused_sub_ctxs):
name = "jvm_ctx",
value = struct(
java_info = providers.java,
kt_info = providers.kt,
providers = [
providers.kt,
providers.java,
],
),
)

def _finalize(ctx, jvm_ctx, **unused_ctxs):
# Call into rules_android for it's finalization logic
android_struct = _android_library_finalize(ctx = ctx, jvm_ctx = jvm_ctx, **unused_ctxs)

# Mirror the resulting provider but stick the legacy `kt` provider into the
# rule result so that Intellij knows to treat our KT targets as Kotlin.
return struct(
kt = jvm_ctx.kt_info,
android = android_struct.android,
java = android_struct.java,
providers = android_struct.providers,
)

PROCESSORS = _processing_pipeline.replace(
_BASE_PROCESSORS,
JvmProcessor = _process_jvm,
Expand Down

0 comments on commit 12dc10d

Please sign in to comment.