Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix java_plugins to work with Android rules #407

Merged
merged 1 commit into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/android/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ maven_install(
"com.google.dagger:dagger:2.28",
"com.google.dagger:dagger-compiler:2.28",
"com.google.dagger:dagger-producers:2.28",
"com.google.auto.value:auto-value:1.6.5",
"com.google.auto.value:auto-value-annotations:1.6.5",
],
repositories = [
"https://jcenter.bintray.com/",
Expand Down
11 changes: 11 additions & 0 deletions examples/android/lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_android_library", "kt_compiler_plugin")
load("@rules_java//java:defs.bzl", "java_plugin")

kt_compiler_plugin(
name = "serialization_plugin",
Expand All @@ -10,17 +11,27 @@ kt_compiler_plugin(
],
)

java_plugin(
name = "autovalue",
generates_api = 1,
processor_class = "com.google.auto.value.processor.AutoValueProcessor",
deps = ["@maven//:com_google_auto_value_auto_value"],
)

kt_android_library(
name = "lib",
srcs = glob(["src/main/kotlin/**/*.kt"]),
custom_package = "examples.android.lib",
manifest = "src/main/AndroidManifest.xml",
plugins = [
":serialization_plugin",
":autovalue",
],
tags = ["trace"],
visibility = ["//visibility:public"],
deps = [
"@maven//:androidx_appcompat_appcompat",
"@maven//:org_jetbrains_kotlinx_kotlinx_serialization_runtime",
"@maven//:com_google_auto_value_auto_value_annotations"
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ class MainActivity : Activity() {
.show()
// Ensure Serialization plugin has run and generated code correctly.
Data.serializer()

AutoValue_TestKtValue.Builder().setName("Auto Value Test").build()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package examples.android.lib

import com.google.auto.value.AutoValue

@AutoValue
abstract class TestKtValue {
abstract fun name(): String
fun builder(): Builder = AutoValue_TestKtValue.Builder()

@AutoValue.Builder
abstract class Builder {
abstract fun setName(name: String): Builder
abstract fun build(): TestKtValue
}
}
2 changes: 1 addition & 1 deletion kotlin/internal/jvm/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def kt_jvm_produce_jar_actions(ctx, rule_kind):
compile_deps = _jvm_deps(
toolchains,
friend,
deps = ctx.attr.deps + ctx.attr.plugins,
deps = ctx.attr.deps,
runtime_deps = ctx.attr.runtime_deps,
)
annotation_processors = _plugin_mappers.targets_to_annotation_processors(ctx.attr.plugins + ctx.attr.deps)
Expand Down