From c7dee10dc9460210283d758b2b0232e238a867a6 Mon Sep 17 00:00:00 2001 From: Ivo List Date: Thu, 22 Dec 2022 13:37:08 +0100 Subject: [PATCH] Decouple Kotlin compiler from Kotlin rules Move Kotlin specific targets (like `kt_jvm_import`) from `BUILD.com_github_jetbrains_kotlin` to `//kotlin/compiler`. This will make it possible to release `kotlin-compiler` module on `bazel-central-registry` without depending on `rules_kotlin`. The release will contain the new form `BUILD.com_github_jetbrains_kotlin` which doesn't depend on `rules_kotlin`. RELNOTES[INC]: This breaks users that depend on `@com_github_jetbrains_kotlin//:*` targets. The same targets can be found under `@io_bazel_rules_kotlin//kotlin/compiler:*`. It's not possible to add an `alias` to `@com_github_jetbrains_kotlin` repository, becuase it would already create a dependency on `rules_kotlin` repository in the bzlmod world. Technically it's possible to release 2 bzlmod modules that have a circular dependency. But this might create some unexpected problems. It addition it would be harder to convince `com_github_jetbrains_kotlin` owners to depend on `rules_kotlin`. Works toward: https://github.com/bazelbuild/rules_kotlin/issues/660 --- README.md | 2 +- docs/kotlin.md | 4 +- examples/android/libKtAndroid/BUILD.bazel | 2 +- examples/plugin/src/allopen/BUILD | 2 +- examples/plugin/src/allopennoarg/BUILD | 6 +- examples/plugin/src/noarg/BUILD | 4 +- examples/plugin/src/parcelize/BUILD | 4 +- examples/plugin/src/sam_with_receiver/BUILD | 2 +- examples/plugin/src/serialization/BUILD | 2 +- kotlin/BUILD | 1 + kotlin/compiler/BUILD | 28 ++++ kotlin/compiler/BUILD.release.bazel | 19 +++ kotlin/compiler/compiler.bzl | 127 ++++++++++++++++++ kotlin/internal/js/js.bzl | 6 +- kotlin/internal/jvm/jvm.bzl | 11 +- kotlin/internal/toolchains.bzl | 12 +- src/main/kotlin/BUILD.release.bazel | 8 +- src/main/kotlin/bootstrap.bzl | 8 +- src/main/kotlin/io/bazel/kotlin/builder/BUILD | 8 +- .../io/bazel/kotlin/builder/cmd/BUILD.bazel | 8 +- .../io/bazel/kotlin/builder/tasks/BUILD.bazel | 2 +- .../kotlin/builder/toolchain/BUILD.bazel | 6 +- .../builder/toolchain/KotlinToolchain.kt | 4 +- .../io/bazel/kotlin/compiler/BUILD.bazel | 6 +- .../kotlin/io/bazel/kotlin/plugin/BUILD.bazel | 2 +- .../io/bazel/kotlin/plugin/jdeps/BUILD.bazel | 2 +- .../BUILD.com_github_jetbrains_kotlin.bazel | 102 -------------- .../starlark/core/repositories/compiler.bzl | 7 - .../core/repositories/initialize.release.bzl | 1 - src/test/kotlin/io/bazel/kotlin/BUILD | 4 +- src/test/kotlin/io/bazel/kotlin/builder/BUILD | 4 +- .../kotlin/builder/KotlinJvmTestBuilder.java | 10 +- src/test/kotlin/io/bazel/kotlin/defs.bzl | 12 +- .../io/bazel/kotlin/integration/BUILD.bazel | 4 +- 34 files changed, 248 insertions(+), 182 deletions(-) create mode 100644 kotlin/compiler/BUILD create mode 100644 kotlin/compiler/BUILD.release.bazel create mode 100644 kotlin/compiler/compiler.bzl diff --git a/README.md b/README.md index 14e1c20ca..956ba0e28 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,7 @@ kt_compiler_plugin( "annotation": "plugin.allopen.OpenForTesting", }, deps = [ - "@com_github_jetbrains_kotlin//:allopen-compiler-plugin", + "@rules_kotlin//kotlin/compiler:allopen-compiler-plugin", ], ) diff --git a/docs/kotlin.md b/docs/kotlin.md index 66170af3e..af9eaa4db 100755 --- a/docs/kotlin.md +++ b/docs/kotlin.md @@ -211,7 +211,7 @@ kt_jvm_test(name, name, ALL_DIRECTORY_TYPES = diff --git a/src/test/kotlin/io/bazel/kotlin/defs.bzl b/src/test/kotlin/io/bazel/kotlin/defs.bzl index f608ed1af..2b66217b9 100644 --- a/src/test/kotlin/io/bazel/kotlin/defs.bzl +++ b/src/test/kotlin/io/bazel/kotlin/defs.bzl @@ -33,12 +33,12 @@ def kt_rules_test(name, **kwargs): "//src/main/kotlin/io/bazel/kotlin/compiler", "//src/main/kotlin:skip-code-gen", "//src/main/kotlin:jdeps-gen", - "@com_github_jetbrains_kotlin//:annotations", - "@com_github_jetbrains_kotlin//:jvm-abi-gen", - "@com_github_jetbrains_kotlin//:kotlin-compiler", - "@com_github_jetbrains_kotlin//:kotlin-stdlib", - "@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7", - "@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk8", + "//kotlin/compiler:annotations", + "//kotlin/compiler:jvm-abi-gen", + "//kotlin/compiler:kotlin-compiler", + "//kotlin/compiler:kotlin-stdlib", + "//kotlin/compiler:kotlin-stdlib-jdk7", + "//kotlin/compiler:kotlin-stdlib-jdk8", ] + args["data"]: if dep not in args["data"]: args["data"].append(dep) diff --git a/src/test/kotlin/io/bazel/kotlin/integration/BUILD.bazel b/src/test/kotlin/io/bazel/kotlin/integration/BUILD.bazel index bbe02ffec..1bf2ffb97 100644 --- a/src/test/kotlin/io/bazel/kotlin/integration/BUILD.bazel +++ b/src/test/kotlin/io/bazel/kotlin/integration/BUILD.bazel @@ -14,7 +14,7 @@ kt_jvm_test( srcs = ["WriteWorkspaceTest.kt"], deps = [ ":lib", - "@com_github_jetbrains_kotlin//:kotlin-test", + "//kotlin/compiler:kotlin-test", "@kotlin_rules_maven//:com_google_truth_truth", "@kotlin_rules_maven//:junit_junit", ], @@ -30,7 +30,7 @@ kt_jvm_test( test_class = "io.bazel.kotlin.integration.MixedSourceCompileTest", deps = [ ":lib", - "@com_github_jetbrains_kotlin//:kotlin-test", + "//kotlin/compiler:kotlin-test", "@kotlin_rules_maven//:com_google_truth_truth", "@kotlin_rules_maven//:junit_junit", ],