rules_kotlin
rules_kotlin copied to clipboard
Release rules_kotlin as a Bazel module
Bazel 5 will bring experimental support for a new system for external dependency management codenamed "bzlmod". Making rules_kotlin available within this system requires packaging it as a module and submitting it to the Bazel Central Registry. Is this already being worked on? I would be willing to help, but do not understand the dependency structure well enough to take this on on my own.
We are looking at it, but we have to look at how this affects those who aren't using 5, and aren't in the modules ecosystem. We're open to it, and ultimately will likely implement this, but if the migration path doesn't support some sort of way out for <5.0 bazel, we'll have to wait a release (of bazel) or two before we really get it done.
In the mean-time, we're looking into the mechanism and setting up a plan. I wouldn't count on this before 1.7 of the rules.
Main problems:
- release tgz contains rkt_1_{4-7}.tgz, legacy.tgz which additionally describe Kotlin/Java compiler flags
- compiler repository depends back on rules_kotlin, to export .jars with
kt_jvm_importrules (circular deps are possible in bzlmod, however they are potentially problematic)
Goal: Make rules_kotlin work with and without bzlmod
I believe there should be just two repositories: rules_kotlin and kotlin_compiler. Bzlmod should handle kotlin_compiler as a dependency as naturally as possible. This then makes it easy for the users to select kotlin_compiler version and rules_kotlin version they want to use.
Proposal:
- Move
kt_jvm_import(andkt_js_import) targets from the kotlin_complier repository into the rules_kotlin repository (just export files instead from kotlin_complier repo) to break dependency edge from compiler repo to rules_kotlin
- alternative, bet that cyclic deps work and just depend on rules_kotlin (we'd need to release rules_kotlin and kotlin_compiler on bazel-central-registry at the same time)
- Release kotlin_compiler 1_4 to 1_7 on bazel-central-registry including the additional bzl files contained in rkt_1_{4,..7} ,
kt_{kotlinc,javac}_optionsrules and{kotlinc,javac}_options_to_flags.- or a more lightweight .bzl file, containing only a string list of available javac and kotlinc flags
- Make rules_kotlin/MODULE.bazel that has a dependency on kotlin_compiler (no repos for rkt_1_x)
There are other minor problems, which I'll attempt to solve separately.
WDYT?
Based on my own experience with the rules_go and gazelle Bazel modules that mutually depend on each other, I can say that this case does work but can also be painful to work with. I would suggest trying to break such cyclic dependencies before Bzlmod-ifying a repo.
I prepared PRs that fix this issue:
- [ ] https://github.com/bazelbuild/rules_kotlin/pull/899
- [ ] https://github.com/bazelbuild/rules_kotlin/pull/900
- [x] https://github.com/bazelbuild/rules_kotlin/pull/901
- [x] https://github.com/bazelbuild/rules_kotlin/pull/896 and
- [ ] https://github.com/bazelbuild/rules_kotlin/pull/902
First two PRs should be reviewed before Kotlin compiler is release on bazel-central-registry.
- Move kt_jvm_import (and kt_js_import) targets from the kotlin_complier repository into the rules_kotlin repository (just export files instead from kotlin_complier repo) to break dependency edge from compiler repo to rules_kotlin
To keep the api stable (and avoid cyclical refs), we can use jvm_import. I've updated the pr.
release tgz contains rkt_1_{4-7}.tgz, legacy.tgz which additionally describe Kotlin/Java compiler flags
If I understand this correctly, the bzlmod does not allow for the practice of "sub repositories" -- instead, it provides extensions. If so, then it's just a matter of remapping the repos to extension and setting a default configuration.
~Also, silly question: how do we register default toolchains?~ Ah, interesting. You can do it in the MODULE.bazel. The docs do not make that clear.
How is it going? I tried to enable bzlmod, but rules_kotlin does not work properly and requires a large number of patches 😢 Then I gave up
Hi! Are there any news from there? Thank you!
Gentle nudge. Would love to be able to use rules_kotlin with bzlmod natively.
+1 this is blocking some folks who depend on rules_kotlin from using bzlmod