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 kt_compiler_plugin not working with android_binary #388

Merged

Conversation

jongerrish
Copy link
Contributor

kt_compiler_plugin currently doesn't work when used from anywhere in the deps of an android-binary target, failing as follows:-

ERROR: /Users/jgerrish/indiekid/rules_kotlin/examples/android/app/BUILD.bazel:29:15: in deps attribute of android_binary rule //app:app3: Dependencies on .jar artifacts are not allowed in Android binaries, please use a java_import to depend on kotlin_rules_maven/v1/https/jcenter.bintray.com/org/jetbrains/kotlin/kotlin-serialization-unshaded/1.4.10/kotlin-serialization-unshaded-1.4.10.jar. If this is an implicit dependency then the rule that introduces it will need to be fixed to account for it correctly.. Since this rule was created by the macro 'android_binary', the error might have been caused by the macro implementation
ERROR: Analysis of target '//app:force_build_apks_test' failed; build aborted: Analysis of target '//app:app3' failed

The fix is not including plugins as part of the compile deps.

Add kt_compiler_plugin to the kt_android_library target referenced by an android_binary update Activity to reference generated code to validate it was run correctly.

@@ -236,7 +236,7 @@ def kt_jvm_compile_action(ctx, rule_kind, output_jar, compile_jar):
dirs = _compiler_directories(ctx)
srcs = _partitioned_srcs(ctx.files.srcs)
friend = _compiler_friends(ctx, friends = getattr(ctx.attr, "friends", []))
compile_deps = _compiler_deps(toolchains, friend, deps = ctx.attr.deps + ctx.attr.plugins)
compile_deps = _compiler_deps(toolchains, friend, deps = ctx.attr.deps)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this sneak in? Or is it part of the fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the fix. Including plugins as compile deps produces the error in the PR description

@jongerrish jongerrish force-pushed the kt_compiler_plugin_android branch from bcfe057 to 720ac92 Compare November 12, 2020 13:55
@jongerrish jongerrish force-pushed the kt_compiler_plugin_android branch from 720ac92 to 53a9577 Compare November 12, 2020 16:29
@jongerrish jongerrish force-pushed the kt_compiler_plugin_android branch from 53a9577 to 1d88017 Compare November 12, 2020 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants