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

Issue using Kotlin BindingAdapters #16

Closed
pswaminathan opened this issue Jan 2, 2022 · 1 comment · Fixed by #17
Closed

Issue using Kotlin BindingAdapters #16

pswaminathan opened this issue Jan 2, 2022 · 1 comment · Fixed by #17
Assignees
Labels
bug Something isn't working

Comments

@pswaminathan
Copy link
Contributor

pswaminathan commented Jan 2, 2022

Sample code here. Without this change, the project builds. Looks like there are two things:

  1. Stubs compilation failing
  2. Moshi Kotlin Codegen plugin not running

Build output:

ERROR: /Users/p/Code/examples/bazel-kt-databinding-crash/app/BUILD:32:22: KotlinCompile //app:app_lib-kotlin { kt: 9, java: 0, srcjars: 1 } for darwin_arm64 failed: (Exit 1): build failed: error executing command bazel-out/host/bin/external/io_bazel_rules_kotlin/src/main/kotlin/build '--flagfile=bazel-out/darwin_arm64-fastbuild/bin/app/app_lib-kotlin-kt-java.jar-0.params'
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                  ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                 ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                     ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                       ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                 ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                   ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                              ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                                ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                                     ^
app/src/main/java/com/example/databinding/Api.kt:5:19: error: unresolved reference: UpdatesJsonAdapter
fun dealWith(uja: UpdatesJsonAdapter) {}
                  ^
Jan 01, 2022 10:20:03 PM worker request 0
SEVERE: Compilation failure: compile phase failed:
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                  ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                 ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                     ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                       ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                 ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                   ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                              ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                                ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                                     ^
/private/var/tmp/_bazel_p/a48d838470da09ddcc3c8b96c3b3efad/execroot/__main__/app/src/main/java/com/example/databinding/Api.kt:5:19: error: unresolved reference: UpdatesJsonAdapter
fun dealWith(uja: UpdatesJsonAdapter) {}
                  ^
io.bazel.kotlin.builder.toolchain.CompilationStatusException: compile phase failed:
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                  ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                 ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                     ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                       ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                 ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                   ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                              ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: not a statement
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                                ^
error: /private/var/folders/71/0r_ylvb13vv2my1_676sx1gm0000gn/T/pwd13981900757377101490/_kotlinc/app-app_lib-kotlin_jvm/generated_java_sources/com/example/databinding/com_example_databinding_Binding_Adapter_Stub.java:22: error: ';' expected
    DataBindingPagedListAdapter<T>.setPagedItems(view, itemLayout, itemContext, items);
                                                                                     ^
/private/var/tmp/_bazel_p/a48d838470da09ddcc3c8b96c3b3efad/execroot/__main__/app/src/main/java/com/example/databinding/Api.kt:5:19: error: unresolved reference: UpdatesJsonAdapter
fun dealWith(uja: UpdatesJsonAdapter) {}
                  ^
	at io.bazel.kotlin.builder.toolchain.CompilationTaskContext.executeCompilerTask(CompilationTaskContext.kt:130)
	at io.bazel.kotlin.builder.toolchain.CompilationTaskContext.executeCompilerTask$default(CompilationTaskContext.kt:114)
	at io.bazel.kotlin.builder.tasks.jvm.Compilation_taskKt$runPlugins$1.invoke(compilation_task.kt:182)
	at io.bazel.kotlin.builder.tasks.jvm.Compilation_taskKt$runPlugins$1.invoke(compilation_task.kt:166)
	at io.bazel.kotlin.builder.toolchain.CompilationTaskContext.execute(CompilationTaskContext.kt:148)
	at io.bazel.kotlin.builder.toolchain.CompilationTaskContext.execute(CompilationTaskContext.kt:140)
	at io.bazel.kotlin.builder.tasks.jvm.Compilation_taskKt.runPlugins(compilation_task.kt:166)
	at io.bazel.kotlin.builder.tasks.jvm.KotlinJvmTaskExecutor.execute(KotlinJvmTaskExecutor.kt:54)
	at io.bazel.kotlin.builder.tasks.KotlinBuilder.executeJvmTask(KotlinBuilder.kt:232)
	at io.bazel.kotlin.builder.tasks.KotlinBuilder.build(KotlinBuilder.kt:130)
	at io.bazel.kotlin.builder.tasks.CompileKotlin.invoke(CompileKotlin.kt:27)
	at io.bazel.worker.PersistentWorker$compileWork$2$result$1.invoke(PersistentWorker.kt:96)
	at io.bazel.worker.PersistentWorker$compileWork$2$result$1.invoke(PersistentWorker.kt:94)
	at io.bazel.worker.WorkerContext$TaskContext.resultOf(WorkerContext.kt:128)
	at io.bazel.worker.WorkerContext.doTask(WorkerContext.kt:156)
	at io.bazel.worker.PersistentWorker$compileWork$2.invokeSuspend(PersistentWorker.kt:94)
	at io.bazel.worker.PersistentWorker$compileWork$2.invoke(PersistentWorker.kt)
	at io.bazel.worker.PersistentWorker$compileWork$2.invoke(PersistentWorker.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
	at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
	at kotlinx.coroutines.BuildersKt.withContext(Unknown Source)
	at io.bazel.worker.PersistentWorker.compileWork(PersistentWorker.kt:93)
	at io.bazel.worker.PersistentWorker.access$compileWork(PersistentWorker.kt:45)
	at io.bazel.worker.PersistentWorker$start$1$1$1$1$2$1.invokeSuspend(PersistentWorker.kt:71)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)Target //app:app_lib failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 31.103s, Critical Path: 4.31s
INFO: 7 processes: 2 internal, 4 darwin-sandbox, 1 worker.
FAILED: Build did NOT complete successfully
@arunkumar9t2 arunkumar9t2 self-assigned this Jan 25, 2022
@arunkumar9t2 arunkumar9t2 added the bug Something isn't working label Jan 25, 2022
arunkumar9t2 pushed a commit that referenced this issue Jan 25, 2022
…nding-adapter-bridge

Support cases where `@BindingAdapter` is statically declared in a class that uses generic in its type params. This change fix code generation to not generate generic information in generated code generics for static access is invalid in Java/Kotlin.

Fixes #16
arunkumar9t2 pushed a commit that referenced this issue Jan 25, 2022
…nding-adapter-bridge

Support cases where `@BindingAdapter` is statically declared in a class that uses generic in its type params. This change fixes code generation to not generate generic information in generated code for those classes since static access is invalid in Java/Kotlin.

Fixes #16
@arunkumar9t2
Copy link
Contributor

arunkumar9t2 commented Jan 25, 2022

Thanks for sharing repro sample, I managed to fix this in #17. There were 3 issues causing the build to fail.

  1. Our processor was generating invalid code when @BindingAdapter is declared in a class that uses generics. Handle cases of using class with generics for @BindingAdapter in binding-adapter-bridge #17 fixes that.
  2. PagedList can't be accessed and throws indirect dependency error. This is a bug in bazel, unfortunately I have not managed to fix that and need to revisit the issue (initially thought it happens only for xml imports, but seems to happen for binding adapter as well). As a workaround, we could use build --experimental_strict_java_deps=off.
  3. BR entires are only added when there is an entry in the XML layout, in the repro sample it was missing.

I fixed the build and created a PR here pswaminathan/bazel-kt-databinding-crash#7

arunkumar9t2 added a commit that referenced this issue Jan 26, 2022
…nding-adapter-bridge (#17)

Support cases where `@BindingAdapter` is statically declared in a class that uses generic in its type params. This change fixes code generation to not generate generic information in generated code for those classes since static access is invalid in Java/Kotlin.

Fixes #16
akshay-grabtaxi pushed a commit that referenced this issue Jun 28, 2023
…nding-adapter-bridge (#17)

Support cases where `@BindingAdapter` is statically declared in a class that uses generic in its type params. This change fixes code generation to not generate generic information in generated code for those classes since static access is invalid in Java/Kotlin.

Fixes #16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants