rules_kotlin
rules_kotlin copied to clipboard
Separate the android and jvm rules so that pure-jvm users don't get stuck with android
Right now, while android native rules are used, this isn't a critical issue - however, once the rules_kotlin start using starlark rules_android, the mixing of jvm and android rules results in a forced dependency on rules_android symbols even for pure-jvm users.
We need to separate things, so that users import the rule sets separately (e.g., not from kotlin:kotlin.bzl). Rather, ensure it's possible for folks to load:
load("@io_bazel_rules_kotlin//kotlin:js.bzl", "kt_js_library")
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@io_bazel_rules_kotlin//kotlin:android.bzl", "kt_android_library")
This will also set the stage for something like:
load("@io_bazel_rules_kotlin//kotlin:pure.bzl", "kt_library")
or however we do kotlin multiplatform.
This should maintain the older kotlin.bzl for compatibility.
Am I correct in understanding this is now an issue? I recently updated rules_kotlin to 1.5.0-beta-2 in a pure-JVM project and getting complaints from Bazel about needing to pull @rules_android as well. Possibly the result of this PR (though I haven't verified): https://github.com/bazelbuild/rules_kotlin/pull/534
+1 for this issue.
Kotlin is our main scripting language for build and CI. Ideally we shouldn't need to pull in Android / Compose for running CI jobs.
Correct me if I'm wrong @cgruber, but I believe this can be remedied in the most recent releases by loading from the correct places (instead of the legacy kotlin.bzl)
I.e. load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library") rather than load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
Similarly for kotlin_repositories, kt_register_toolchains, etc. they should now be loaded as follows:
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")
Any updates on this, just getting into Kotlin and I intend on using it in this use case(ie not android)