aboutsummaryrefslogtreecommitdiff
path: root/kotlin
diff options
context:
space:
mode:
authorDonald Duo Zhao <deltazulu@google.com>2022-11-30 17:54:17 -0800
committerCopybara-Service <copybara-worker@google.com>2022-11-30 17:54:54 -0800
commiteb399f847060ccaabcd0a7fd2d57a064a67b1bdb (patch)
tree6d97fda933921b7a7a8e85ac28fe3ab1cdc4344a /kotlin
parent441ec46966b3472e30bfa421d2731e55a23f56e2 (diff)
downloadbazelbuild-kotlin-rules-eb399f847060ccaabcd0a7fd2d57a064a67b1bdb.tar.gz
NONE
PiperOrigin-RevId: 492067716
Diffstat (limited to 'kotlin')
-rw-r--r--kotlin/common.bzl3
-rw-r--r--kotlin/java_plugin.internal.bzl2
-rw-r--r--kotlin/jvm_compile.bzl31
3 files changed, 20 insertions, 16 deletions
diff --git a/kotlin/common.bzl b/kotlin/common.bzl
index 601b43e..6172520 100644
--- a/kotlin/common.bzl
+++ b/kotlin/common.bzl
@@ -802,6 +802,7 @@ def _kt_jvm_library(
output = None,
output_srcjar = None, # Will derive default filename if not set.
deps = [],
+ codegen_output_java_infos = [], # JavaInfo sequence from kt_codegen_plugin.
exports = [], # passthrough for JavaInfo constructor
runtime_deps = [], # passthrough for JavaInfo constructor
native_libraries = [], # passthrough of CcInfo for JavaInfo constructor
@@ -850,7 +851,7 @@ def _kt_jvm_library(
if srcs or common_srcs or rule_family != _RULE_FAMILY.ANDROID_LIBRARY:
deps.extend(kt_toolchain.kotlin_libs)
- merged_deps = java_common.merge(deps)
+ merged_deps = java_common.merge(deps + codegen_output_java_infos)
# Skip srcs package check for android_library targets with no kotlin sources: b/239725424
if rule_family != _RULE_FAMILY.ANDROID_LIBRARY or kt_srcs:
diff --git a/kotlin/java_plugin.internal.bzl b/kotlin/java_plugin.internal.bzl
index 08f5463..69e7bb5 100644
--- a/kotlin/java_plugin.internal.bzl
+++ b/kotlin/java_plugin.internal.bzl
@@ -22,7 +22,7 @@ from the way that java targets handles plugins.
def _get_java_plugins(_target, ctx_rule):
exported_plugins = getattr(ctx_rule.attr, "exported_plugins", [])
return [
- t[JavaPluginInfo]
+ t[JavaPluginInfo].plugins
for t in exported_plugins
if JavaPluginInfo in t
]
diff --git a/kotlin/jvm_compile.bzl b/kotlin/jvm_compile.bzl
index d772f80..4139150 100644
--- a/kotlin/jvm_compile.bzl
+++ b/kotlin/jvm_compile.bzl
@@ -118,6 +118,20 @@ def kt_jvm_compile(
srcs = list(srcs)
classpath_resources = list(classpath_resources)
java_infos = []
+ codegen_output_java_infos = []
+
+ # The r_java field only support Android resources Jar files. For now, verify
+ # that the name of the jar matches "_resources.jar". This check does not to
+ # prevent malicious use, the intent is to prevent accidental usage.
+ r_java_infos = []
+ if r_java:
+ for jar in r_java.outputs.jars:
+ if not jar.class_jar.path.endswith("_resources.jar"):
+ fail("Error, illegal dependency provided for r_java. This " +
+ "only supports Android resource Jar files, " +
+ "'*_resources.jar'.")
+ r_java_infos.append(r_java)
+
pre_processed_java_plugin_processors = sets.make([])
# Skip deps validation check for any android_library target with no kotlin sources: b/239721906
@@ -136,18 +150,6 @@ def kt_jvm_compile(
if kotlincopts != None and "-Werror" in kotlincopts:
fail("Flag -Werror is not permitted")
- # The r_java field only support Android resources Jar files. For now, verify
- # that the name of the jar matches "_resources.jar". This check does not to
- # prevent malicious use, the intent is to prevent accidental usage.
- r_java_info = []
- if r_java:
- for jar in r_java.outputs.jars:
- if not jar.class_jar.path.endswith("_resources.jar"):
- fail("Error, illegal dependency provided for r_java. This " +
- "only supports Android resource Jar files, " +
- "'*_resources.jar'.")
- r_java_info.append(r_java)
-
return common.kt_jvm_library(
ctx,
android_lint_plugins = [p[JavaInfo] for p in android_lint_plugins],
@@ -155,11 +157,12 @@ def kt_jvm_compile(
classpath_resources = classpath_resources,
common_srcs = common_srcs,
coverage_srcs = coverage_srcs,
- deps = r_java_info + java_infos,
+ deps = r_java_infos + java_infos,
+ codegen_output_java_infos = codegen_output_java_infos,
disable_lint_checks = disable_lint_checks,
exported_plugins = [e[JavaPluginInfo] for e in exported_plugins if (JavaPluginInfo in e)],
# Not all exported targets contain a JavaInfo (e.g. some only have CcInfo)
- exports = r_java_info + [e[JavaInfo] for e in exports if JavaInfo in e],
+ exports = r_java_infos + [e[JavaInfo] for e in exports if JavaInfo in e],
friend_jars = kt_traverse_exports.expand_friend_jars(deps, root = ctx),
java_toolchain = java_toolchain,
javacopts = javacopts,