Skip to content

Commit

Permalink
[KT] Split out package-info files into their own compilation for J2KT…
Browse files Browse the repository at this point in the history
… Web

`package-info.java` files are the only Java sources that persist through J2KT as
there's no Kotlin equivalent of them. Before J2KT runs we'll run annotation
processors and ultimately transpile any outputs to Kotlin. Therefore, there's no
need to run them again. However, the current setup has us running annotation
processors as second time as part of the Kotlin compilation.

The obvious approach would be to simply not pass through `plugins`, however this
has two issues:

  1. because plugins are exported, some of them will be coming from the
     `JavaInfo` providers on the `deps`. These `deps` may not be J2KT libraries.
  2. this would also disable running any KAPT plugins

The easiest way to avoid this problem is to split out the `package-info.java`
files into their own Java compilation with annotation processing disabled. We'll
then thread this into the Kotlin compilation as an extra dep/export.

PiperOrigin-RevId: 587897154
  • Loading branch information
kevinoconnor7 authored and copybara-github committed Dec 5, 2023
1 parent b87e7ef commit ce954d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions build_defs/internal_do_not_use/j2cl_common.bzl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Common utilities for creating J2CL targets and providers."""

load(":provider.bzl", "J2clInfo")
load(":j2cl_js_common.bzl", "J2CL_JS_TOOLCHAIN_ATTRS", "create_js_lib_struct", "j2cl_js_provider")
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load(":j2cl_js_common.bzl", "J2CL_JS_TOOLCHAIN_ATTRS", "create_js_lib_struct", "j2cl_js_provider")
load(":provider.bzl", "J2clInfo")

def _get_jsinfo_provider(j2cl_info):
return j2cl_info._private_.js_info
Expand Down

0 comments on commit ce954d0

Please sign in to comment.