Skip to content

Define and use multiple kotlin toolchains in the same project #1430

@johngun3

Description

@johngun3

I have the following use case: I want to build a set of targets with Kotlin 1.4 and I want to build other targets with Kotlin 1.7 in the same workspace. That is because I have a monorepo bazel project where I want to create and publish kotlin libraries that are able to be incorporated into external builds that use different versions of the kotlin compiler. From what I can tell, it doesn't seem to be possible to declare multiple kotlin toolchains with different versions and use them for a couple of reasons:

  1. kotlin_home is hardcoded to point to @com_github_jetbrains_kotlin/ in _kt_toolchain regardless of what versions of the kotlin compiler are installed. Generally speaking com_github_jetbrains_kotlin is hardcoded in a lot of places.
  2. The build jvm_binary defined in src/main/kotlin/BUILD.release.bazel is compiled with jvm_args that hardcode the paths of expected jar files to the same location regardless of compiler version. Generally speaking,

Is it possible accomplish my goal? If so, could you give me some guidance on how to go about it? I'm attempting to do with this version 1.7.1 of rules_kotlin but I've taken a look at the most recent version and it doesn't seem like the two issues I've mentioned above have been resolved. I'd appreciate any guidance you're willing to give.

I think my best option might be to checkout the other version ofrules_kotlin that I want to use, modify all the relevant hardcoded paths, build everything, and then I'll be able to import that other package as a second repository rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions