rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

How do define multiple Toolchains?

Open ed-irl opened this issue 1 year ago • 0 comments

I would like to be able to define and use multiple Kotlin toolchains in my project, which uses bzlmod. I would like to be able to have one toolchain with strict_deps and unused_deps and one without.

This itself is a byproduct of how jvm_test_suite works. For convenience sake, since you have one shared set of test dependencies, the dependencies supplied to jvm_test_suite must consist of the common dependencies of all your tests. At the same time, some of those dependencies may also go unused (eg. test-coroutines may not be used in every test).

The declaration of multiple toolchains itself is possible via the define_kt_toolchain macro, but the macro elides the exec_compatible_with and target_compatible_with attributes of native.toolchain, which is how I think I should select the appropriate toolchain. For whatever reason, the docs discourage users from directly defining Kotlin toolchains.

Is there another way to define and select among multiple toolchains that is encouraged? If not, perhaps you have guidance on dealing with the test dependencies issue?

Thank you!

ed-irl avatar Aug 12 '24 13:08 ed-irl