Skip to content

Commit

Permalink
Support multiple kt_android_library targets with same package name. F…
Browse files Browse the repository at this point in the history
…ixes #787 (#790)

When two `kt_android_library` or `android_library` has the same package name either provided via `custom_package` or due to same package name in `AndroidManifest.xml`, R class fields from current module's resources were not compilable due to order of jars appearing in `--direct_dependencies`.

This CL ensure the merged resources jar always comes first.
  • Loading branch information
arunkumar9t2 authored Jun 29, 2022
1 parent 9e4363b commit 5f86721
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions examples/android/libKtAndroid/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ kt_android_library(
tags = ["trace"],
visibility = ["//visibility:public"],
deps = [
":res2",
"@maven//:androidx_appcompat_appcompat",
"@maven//:com_google_auto_value_auto_value_annotations",
"@maven//:org_jetbrains_kotlinx_kotlinx_serialization_runtime",
],
)

android_library(
name = "res2",
custom_package = "examples.android.lib",
manifest = "src/main/AndroidManifest.xml",
resource_files = glob(["res2/**"]),
)
3 changes: 3 additions & 0 deletions examples/android/libKtAndroid/res2/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="hello">hello?</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MainActivity : AppCompatActivity() {
setContentView(parent, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
AlertDialog.Builder(this)
.setTitle(this.getString(R.string.where_you_at))
.setMessage("Blah blah blah?")
.setMessage("Blah blah blah? " + getString(R.string.hello))
.show()
// Ensure Serialization plugin has run and generated code correctly.
Data.serializer()
Expand Down
2 changes: 1 addition & 1 deletion kotlin/internal/jvm/android.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _kt_android_artifact(
_kt_jvm_library(
name = kt_name,
srcs = srcs,
deps = base_deps + [base_name],
deps = [base_name] + base_deps,
resources = resources,
plugins = plugins,
associates = associates,
Expand Down

0 comments on commit 5f86721

Please sign in to comment.