aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Duo Zhao <deltazulu@google.com>2023-01-26 16:52:26 -0800
committerCopybara-Service <copybara-worker@google.com>2023-01-26 16:52:56 -0800
commit4616d7f6468ff3bb533435bb3cd6e37a35780c7c (patch)
tree5303e68dae8dee94599f550f5dfc90577b4904dc
parent3569a759f416d02e34063526559718f751f77c8d (diff)
downloadbazelbuild-kotlin-rules-4616d7f6468ff3bb533435bb3cd6e37a35780c7c.tar.gz
NONE
PiperOrigin-RevId: 504976597
-rw-r--r--kotlin/common.bzl29
-rw-r--r--kotlin/jvm_compile.bzl6
2 files changed, 13 insertions, 22 deletions
diff --git a/kotlin/common.bzl b/kotlin/common.bzl
index 73b170b..73fde72 100644
--- a/kotlin/common.bzl
+++ b/kotlin/common.bzl
@@ -811,7 +811,7 @@ def _kt_jvm_library(
runtime_deps = [], # passthrough for JavaInfo constructor
native_libraries = [], # passthrough of CcInfo for JavaInfo constructor
plugins = _kt_plugins_map(),
- pre_processed_java_plugin_processors = sets.make([]),
+ pre_processed_processors = sets.make([]),
exported_plugins = [],
android_lint_plugins = [],
android_lint_rules_jars = depset(), # Depset with standalone Android Lint rules Jars
@@ -871,7 +871,7 @@ def _kt_jvm_library(
cls
for p in java_plugin_datas
for cls in p.processor_classes.to_list()
- if not sets.contains(pre_processed_java_plugin_processors, cls)
+ if not sets.contains(pre_processed_processors, cls)
]
plugin_classpaths = depset(transitive = [p.processor_jars for p in java_plugin_datas])
@@ -965,15 +965,12 @@ def _kt_jvm_library(
javac_deps.append(kt_toolchain.coverage_runtime)
javac_out = output if is_android_library_without_kt_srcs else file_factory.declare_file("-java.jar")
- allow_indirect_dep_access = _contains_srcs_with_sjd_exemption(srcs)
+
annotation_plugins = list(plugins.java_plugin_infos)
- if allow_indirect_dep_access:
- annotation_plugins.append(
- JavaPluginInfo(
- processor_class = "_KtCodegenProcessed",
- runtime_deps = [],
- ),
- )
+
+ # Enable annotation processing for java-only sources to enable data binding
+ enable_annotation_processing = not kt_srcs
+
javac_java_info = java_common.compile(
ctx,
source_files = java_srcs,
@@ -993,9 +990,7 @@ def _kt_jvm_library(
strict_deps = "DEFAULT",
java_toolchain = java_toolchain,
neverlink = neverlink,
- # Enable annotation processing for java-only sources to enable data binding
- # Disable annotation processing if the srcs have already been processed.
- enable_annotation_processing = (not kt_srcs) and (not allow_indirect_dep_access),
+ enable_annotation_processing = enable_annotation_processing,
annotation_processor_additional_outputs = annotation_processor_additional_outputs,
annotation_processor_additional_inputs = annotation_processor_additional_inputs,
)
@@ -1225,14 +1220,6 @@ def _collect_providers(provider, deps):
"""Collects the requested provider from the given list of deps."""
return [dep[provider] for dep in deps if provider in dep]
-# Allows certain generated sources to be exempted from strict deps. Configuration at,
-# google3/tools/build_defs/kotlin/policy/codegen_plugin.bzl#_PROCESSOR_PREFIXES_WITH_SJD_EXEMPTION
-def _contains_srcs_with_sjd_exemption(srcs):
- for src in srcs:
- if "_non_strict_" in src.path:
- return True
- return False
-
def _create_classpath(java_toolchain, deps):
# To not confuse strictdeps, order as boot > direct > transitive JARs (b/149107867).
return depset(
diff --git a/kotlin/jvm_compile.bzl b/kotlin/jvm_compile.bzl
index 4139150..f36eb75 100644
--- a/kotlin/jvm_compile.bzl
+++ b/kotlin/jvm_compile.bzl
@@ -133,6 +133,7 @@ def kt_jvm_compile(
r_java_infos.append(r_java)
pre_processed_java_plugin_processors = sets.make([])
+ pre_processed_kt_codegen_plugin_processors = sets.make([])
# Skip deps validation check for any android_library target with no kotlin sources: b/239721906
has_kt_srcs = any([common.is_kt_src(src) for src in srcs])
@@ -184,7 +185,10 @@ def kt_jvm_compile(
if (KtCompilerPluginInfo in plugin)
],
),
- pre_processed_java_plugin_processors = pre_processed_java_plugin_processors,
+ pre_processed_processors = sets.union(
+ pre_processed_java_plugin_processors,
+ pre_processed_kt_codegen_plugin_processors,
+ ),
resource_files = resource_files,
runtime_deps = [d[JavaInfo] for d in runtime_deps if JavaInfo in d],
srcs = srcs,