Skip to content

Commit

Permalink
Fix kt_compiler_plugin not working with android_binary
Browse files Browse the repository at this point in the history
  • Loading branch information
jongerrish committed Nov 12, 2020
1 parent 54c5ec8 commit bcfe057
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
13 changes: 12 additions & 1 deletion examples/android/lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library")
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_compiler_plugin", "kt_android_library")

kt_compiler_plugin(
name = "serialization_plugin",
deps = [
"@com_github_jetbrains_kotlin//:kotlinx-serialization-compiler-plugin",
],
)

kt_android_library(
name = "lib",
Expand All @@ -7,6 +14,10 @@ kt_android_library(
manifest = "src/main/AndroidManifest.xml",
visibility = ["//visibility:public"],
deps = [
"@kotlin_rules_maven//:org_jetbrains_kotlinx_kotlinx_serialization_runtime",
"@maven//:androidx_appcompat_appcompat",
],
plugins = [
":serialization_plugin",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ class MainActivity : Activity() {
.setTitle("Blah")
.setMessage("Blah blah blah?")
.show()
// Ensure Serialization plugin has run and generated code correctly.
Data.serializer()
}
}
2 changes: 1 addition & 1 deletion kotlin/internal/jvm/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def kt_jvm_compile_action(ctx, rule_kind, output_jar, compile_jar):
dirs = _compiler_directories(ctx)
srcs = _partitioned_srcs(ctx.files.srcs)
friend = _compiler_friends(ctx, friends = getattr(ctx.attr, "friends", []))
compile_deps = _compiler_deps(toolchains, friend, deps = ctx.attr.deps + ctx.attr.plugins)
compile_deps = _compiler_deps(toolchains, friend, deps = ctx.attr.deps)
annotation_processors = _plugin_mappers.targets_to_annotation_processors(ctx.attr.plugins + ctx.attr.deps)
transitive_runtime_jars = _plugin_mappers.targets_to_transitive_runtime_jars(ctx.attr.plugins + ctx.attr.deps)
plugins = ctx.attr.plugins
Expand Down

0 comments on commit bcfe057

Please sign in to comment.