simplify the plugin aspect rollup
diff --git a/kotlin/internal/jvm/android.bzl b/kotlin/internal/jvm/android.bzl
index 8da7540..2ec9398 100644
--- a/kotlin/internal/jvm/android.bzl
+++ b/kotlin/internal/jvm/android.bzl
@@ -18,7 +18,8 @@
def _kt_android_artifact(name, srcs = [], deps = [], plugins = [], **kwargs):
"""Delegates Android related build attributes to the native rules but uses the Kotlin builder to compile Java and
- Kotlin srcs. Returns a sequence of labels that a wrapping macro should export."""
+ Kotlin srcs. Returns a sequence of labels that a wrapping macro should export.
+ """
base_name = name + "_base"
kt_name = name + "_kt"
@@ -37,7 +38,7 @@
return [base_name, kt_name]
def kt_android_library(name, exports = [], visibility = None, **kwargs):
- """Creates a Android sandwich library. `srcs`, `deps`, `plugins` are routed to `kt_jvm_library` the other android
+ """Creates an Android sandwich library. `srcs`, `deps`, `plugins` are routed to `kt_jvm_library` the other android
related attributes are handled by the native `android_library` rule.
"""
native.android_library(
diff --git a/kotlin/internal/jvm/compile.bzl b/kotlin/internal/jvm/compile.bzl
index 6ef2616..7fa6fa3 100644
--- a/kotlin/internal/jvm/compile.bzl
+++ b/kotlin/internal/jvm/compile.bzl
@@ -18,7 +18,7 @@
)
load(
"//kotlin/internal/jvm:plugins.bzl",
- _merge_plugin_infos = "merge_plugin_infos"
+ _merge_plugin_infos = "merge_plugin_infos",
)
load(
"//kotlin/internal/utils:utils.bzl",
@@ -143,7 +143,7 @@
Args:
rule_kind: The rule kind --e.g., `kt_jvm_library`.
- output_jar: The jar file that this macro will use as the output of the action.
+ output_jar: The jar file that this macro will use as the output.
Returns:
A struct containing the providers JavaInfo (`java`) and `kt` (KtJvmInfo). This struct is not intended to be
used as a legacy provider -- rather the caller should transform the result.
@@ -254,7 +254,12 @@
)
def kt_jvm_produce_jar_actions(ctx, rule_kind):
- """Setup The actions to compile a jar and merge additional resources onto it. see `kt_jvm_compile_action`."""
+ """Setup The actions to compile a jar and if any resources or resource_jars were provided to merge these in with the
+ compilation output.
+
+ Returns:
+ see `kt_jvm_compile_action`.
+ """
# The jar that is compiled from sources.
output_jar = ctx.outputs.jar
diff --git a/kotlin/internal/jvm/plugins.bzl b/kotlin/internal/jvm/plugins.bzl
index f6a1790..2089b7d 100644
--- a/kotlin/internal/jvm/plugins.bzl
+++ b/kotlin/internal/jvm/plugins.bzl
@@ -11,6 +11,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+load(
+ "//kotlin/internal/utils:utils.bzl",
+ _utils = "utils",
+)
+
KtJvmPluginInfo = provider(
doc = "This provider contains the plugin info for the JVM aspect",
fields = {
@@ -18,27 +23,12 @@
},
)
-def _mk_processor_entry(l, p):
- merged_info = java_common.merge([j[JavaInfo] for j in p.deps])
- classpath_jars = depset([cp for cp in merged_info.full_compile_jars])
- classpath_jars = classpath_jars + merged_info.transitive_runtime_jars
- return struct(
- label = l,
- processor_class = p.processor_class,
- classpath = [cpj.path for cpj in classpath_jars.to_list()],
- generates_api = p.generates_api,
- )
-
-def _restore_label(l):
- lbl = l.workspace_root
- if lbl.startswith("external/"):
- lbl = lbl.replace("external/", "@")
- return lbl + "//" + l.package + ":" + l.name
-
_EMPTY_PLUGIN_INFO = [KtJvmPluginInfo(annotation_processors = [])]
def merge_plugin_infos(attrs):
- """Merge all of the plugin infos found in the provided sequence of attributes."""
+ """Merge all of the plugin infos found in the provided sequence of attributes.
+ Returns:
+ A KtJvmPluginInfo provider, Each of the entries is serializable."""
tally = {}
annotation_processors = []
for info in [a[KtJvmPluginInfo] for a in attrs]:
@@ -52,8 +42,17 @@
def _kt_jvm_plugin_aspect_impl(target, ctx):
if ctx.rule.kind == "java_plugin":
+ processor = ctx.rule.attr
+ merged_deps = java_common.merge([j[JavaInfo] for j in processor.deps])
return [KtJvmPluginInfo(
- annotation_processors = [_mk_processor_entry(_restore_label(ctx.label), ctx.rule.attr)],
+ annotation_processors = [
+ struct(
+ label = _utils.restore_label(ctx.label),
+ processor_class = processor.processor_class,
+ classpath = [cp.path for cp in merged_deps.transitive_runtime_jars],
+ generates_api = processor.generates_api,
+ ),
+ ],
)]
elif ctx.rule.kind == "java_library":
return [merge_plugin_infos(ctx.rule.attr.exported_plugins)]