rules_kotlin icon indicating copy to clipboard operation
rules_kotlin copied to clipboard

How to add kotlin compiler option ?

Open scorsi opened this issue 5 years ago • 3 comments

Hello,

I'm trying to add the -Xuse-experimental=kotlin.contracts.ExperimentalContracts option to the compiler and I really don't understand how to manage that.

Is it with the kt_compiler_plugin ?

/plugins/BUILD.bazel:

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_compiler_plugin")

package(default_visibility = ["//visibility:public"])

kt_compiler_plugin(
    name = "experimental_contracts",
    options = {
        "use-experimental": "kotlin.contracts.ExperimentalContracts", # -X... and X... don't work too
    },
)

/my-lib/BUILD.bazel:

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")

package(default_visibility = ["//visibility:public"])

kt_jvm_library(
    name = "lib",
    srcs = glob(["src/**/*.kt"]),
    plugins = [
        "//plugins:experimental_contracts"
    ],
    deps = [
        "...",
    ]
)

Thanks,

scorsi avatar Jun 24 '20 14:06 scorsi

@scorsi did you ever figure this out?

jeffzoch avatar Sep 30 '20 22:09 jeffzoch

I never success to manage this and to be honnest I dis stop using the Kotlin rule. But I am sure to not be the only looking for a solution to that issue.

scorsi avatar Oct 01 '20 04:10 scorsi

This sounds like #23

Kernald avatar Oct 19 '21 02:10 Kernald