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 class_info.to_list() #10

Closed
wants to merge 2 commits into from
Closed

Conversation

pswaminathan
Copy link
Contributor

The first commit addresses a crash. On master, with Bazel 4.2.2 (I'm not sure if this was a change stemming from Bazel 4):

$ bazel build //...
DEBUG: /private/var/tmp/_bazel_p/a48d838470da09ddcc3c8b96c3b3efad/external/io_bazel_rules_kotlin/kotlin/kotlin.bzl:116:10: kt_jvm_library should be loaded from //kotlin:jvm.bzl
DEBUG: /private/var/tmp/_bazel_p/a48d838470da09ddcc3c8b96c3b3efad/external/io_bazel_rules_kotlin/kotlin/kotlin.bzl:116:10: kt_jvm_library should be loaded from //kotlin:jvm.bzl
DEBUG: /private/var/tmp/_bazel_p/a48d838470da09ddcc3c8b96c3b3efad/external/io_bazel_rules_kotlin/kotlin/kotlin.bzl:116:10: kt_jvm_library should be loaded from //kotlin:jvm.bzl
ERROR: /Users/p/Code/examples/bazel-kt-databinding-crash/BUILD:17:22: in databinding_stubs rule //:app_lib-stubs:
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_p/a48d838470da09ddcc3c8b96c3b3efad/external/grab_bazel_common/tools/databinding/databinding_stubs.bzl", line 54, column 68, in _databinding_stubs_impl
		for class_info in target[DataBindingV2Info].class_infos.to_list():
Error: 'list' value has no field or method 'to_list'
ERROR: Analysis of target '//:r-classes' failed; build aborted: Analysis of target '//:app_lib-stubs' failed
INFO: Elapsed time: 15.201s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (12 packages loaded, 721 targets configured)

This PR also changes the import path for kt_jvm_library to remove the debug messages from rules_kotlin. LMK if you'd rather have that in a separate PR—happy to split it out.

@arunkumar9t2 arunkumar9t2 added the enhancement New feature or request label Dec 14, 2021
@arunkumar9t2
Copy link
Contributor

Thanks for the PR! This looks good to me. I would appreciate if the PR is split for the Kotlin import change.

The to_list() change was made to support Bazel 5.0 changes. Reference: bazelbuild/bazel#12780

Probably we need a compat version that support both versions like done on rules_android.

def _list_or_depset_to_list(list_or_depset):
    if type(list_or_depset) == "list":
        return list_or_depset
    elif type(list_or_depset) == "depset":
        return list_or_depset.to_list()
    else:
        return _error("Expected a list or a depset. Got %s" % type(list_or_depset))

@pswaminathan
Copy link
Contributor Author

Ah, wonderful. Submitted as #11 and #12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants