-
Notifications
You must be signed in to change notification settings - Fork 213
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
Support multiple kt_android_library
targets with same package name.
#790
Support multiple kt_android_library
targets with same package name.
#790
Conversation
kt_android_library
targets with same package name. Fixes #787kt_android_library
targets with same package name.
Fixes #787 |
Did you try inverting the base_deps and base_name in https://github.com/bazelbuild/rules_kotlin/blob/master/kotlin/internal/jvm/android.bzl#L56? It would be much less invasive that changing the order inside the rules. |
kotlin/internal/jvm/compile.bzl
Outdated
@@ -51,6 +51,11 @@ load( | |||
def _java_info(target): | |||
return target[JavaInfo] if JavaInfo in target else None | |||
|
|||
def _is_android_sandwich(current_label_name, target): | |||
"""Checks if the given target is <target>_base target from android sandwich macro""" | |||
is_base_target = current_label_name.removesuffix("_kt") == target.label.name.removesuffix("_base") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't work on Bazel versions older than 5.1.0, bazelbuild/bazel#14899
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nikolas-LFDesigns thanks, I removed this impl and just switched the order in deps
attribute. That also worked.
1b08d68
to
62c5d7f
Compare
…ixes bazelbuild#787 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.
62c5d7f
to
c69a774
Compare
Thanks @corbinrsmith, that worked as well. Updated PR. |
kotlin/internal/jvm/compile.bzl
Outdated
@@ -89,7 +94,7 @@ def _compiler_toolchains(ctx): | |||
java_runtime = find_java_runtime_toolchain(ctx, ctx.attr._host_javabase), | |||
) | |||
|
|||
def _jvm_deps(toolchains, associated_targets, deps, runtime_deps = []): | |||
def _jvm_deps(current_label_name, toolchains, associated_targets, deps, runtime_deps = []): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't infer off label name -- too brittle.
When two
kt_android_library
orandroid_library
has the same package name either provided viacustom_package
or due to same package name inAndroidManifest.xml
,R
class fields from current module's resources were not compilable due to order of jars appearing in--direct_dependencies
.The current module's resources jar would contain merged
R
class from all dependencies but because it appears later in the list, the dependencies'R
class is used which does not contain merged R class. The problem only appears when two targets contains the same package name.The fix is similar to one applied in Bazel
This PR ensures the merged resources jar always comes ensuring order in deps attribute