diff --git a/MODULE.bazel b/MODULE.bazel index 273d8bd9b..3828307fc 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -20,6 +20,9 @@ use_repo( "com_github_jetbrains_kotlin", "com_github_jetbrains_kotlin_git", "com_github_pinterest_ktlint", + "kotlinx_serialization_core_jvm", + "kotlinx_serialization_json", + "kotlinx_serialization_json_jvm", "released_rules_kotlin", ) diff --git a/MODULE.release.bazel b/MODULE.release.bazel index b2348946a..517e2d1f6 100644 --- a/MODULE.release.bazel +++ b/MODULE.release.bazel @@ -21,6 +21,9 @@ use_repo( "com_github_google_ksp", "com_github_jetbrains_kotlin", "com_github_pinterest_ktlint", + "kotlinx_serialization_core_jvm", + "kotlinx_serialization_json", + "kotlinx_serialization_json_jvm", ) register_toolchains("//kotlin/internal:default_toolchain") diff --git a/docs/kotlin.md b/docs/kotlin.md index e7ed27e35..1cd4d8525 100755 --- a/docs/kotlin.md +++ b/docs/kotlin.md @@ -575,8 +575,8 @@ Call this in the WORKSPACE file to setup the Kotlin rules. | is_bzlmod |
-
| `False` | | compiler_repository_name | for the kotlinc compiler repository. | `"com_github_jetbrains_kotlin"` | | ksp_repository_name |-
| `"com_github_google_ksp"` | -| compiler_release | version provider from versions.bzl. | `struct(sha256 = "ef578730976154fd2c5968d75af8c2703b3de84a78dffe913f670326e149da3b", url_templates = ["https://github.com/JetBrains/kotlin/releases/download/v{version}/kotlin-compiler-{version}.zip"], version = "2.0.0")` | -| ksp_compiler_release | (internal) version provider from versions.bzl. | `struct(sha256 = "84100aed5b63effa992ce6574b3ba47d2dbb78529752daa4c181e203117ba7de", url_templates = ["https://github.com/google/ksp/releases/download/{version}/artifacts.zip"], version = "2.0.0-1.0.21")` | +| compiler_release | version provider from versions.bzl. | `struct(sha256 = "88d7d8bad362ae4e114a8b9668c6887b8c85f48e340883db0e317e47c8dc2f4f", url_templates = ["https://github.com/JetBrains/kotlin/releases/download/v{version}/kotlin-compiler-{version}.zip"], version = "2.0.10")` | +| ksp_compiler_release | (internal) version provider from versions.bzl. | `struct(sha256 = "e6a79e649ee383b372fa982be89686c10ee42b25e60147b3271a70fd75a9eb19", url_templates = ["https://github.com/google/ksp/releases/download/{version}/artifacts.zip"], version = "2.0.10-1.0.24")` | diff --git a/src/main/kotlin/BUILD.release.bazel b/src/main/kotlin/BUILD.release.bazel index 5f04f0e85..91ad31c96 100644 --- a/src/main/kotlin/BUILD.release.bazel +++ b/src/main/kotlin/BUILD.release.bazel @@ -47,8 +47,14 @@ java_binary( "//kotlin/compiler:symbol-processing-cmdline", "//src/main/kotlin/io/bazel/kotlin/compiler", "@com_github_jetbrains_kotlin//:home", + "@kotlinx_serialization_core_jvm//jar", + "@kotlinx_serialization_json//jar", + "@kotlinx_serialization_json_jvm//jar", ], jvm_flags = [ + "-D@com_github_jetbrains_kotlinx...serialization-core-jvm=$(rlocationpath @kotlinx_serialization_core_jvm//jar)", + "-D@com_github_jetbrains_kotlinx...serialization-json=$(rlocationpath @kotlinx_serialization_json//jar)", + "-D@com_github_jetbrains_kotlinx...serialization-json-jvm=$(rlocationpath @kotlinx_serialization_json_jvm//jar)", "-D@com_github_jetbrains_kotlin...jvm-abi-gen=$(rlocationpath //kotlin/compiler:jvm-abi-gen)", "-D@com_github_jetbrains_kotlin...kotlin-compiler=$(rlocationpath //kotlin/compiler:kotlin-compiler)", "-D@com_github_jetbrains_kotlin...kapt=$(rlocationpath //kotlin/compiler:kotlin-annotation-processing)", diff --git a/src/main/kotlin/io/bazel/kotlin/builder/cmd/BUILD.bazel b/src/main/kotlin/io/bazel/kotlin/builder/cmd/BUILD.bazel index 06363c3b8..b5195827f 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/cmd/BUILD.bazel +++ b/src/main/kotlin/io/bazel/kotlin/builder/cmd/BUILD.bazel @@ -25,8 +25,14 @@ kt_bootstrap_binary( "//src/main/kotlin:skip-code-gen", "//src/main/kotlin/io/bazel/kotlin/compiler:compiler.jar", "@com_github_jetbrains_kotlin//:home", + "@kotlinx_serialization_core_jvm//jar", + "@kotlinx_serialization_json//jar", + "@kotlinx_serialization_json_jvm//jar", ], jvm_flags = [ + "-D@com_github_jetbrains_kotlinx...serialization-core-jvm=$(rlocationpath @kotlinx_serialization_core_jvm//jar)", + "-D@com_github_jetbrains_kotlinx...serialization-json=$(rlocationpath @kotlinx_serialization_json//jar)", + "-D@com_github_jetbrains_kotlinx...serialization-json-jvm=$(rlocationpath @kotlinx_serialization_json_jvm//jar)", "-D@com_github_jetbrains_kotlin...jvm-abi-gen=$(rlocationpath //kotlin/compiler:jvm-abi-gen)", "-D@com_github_jetbrains_kotlin...kotlin-compiler=$(rlocationpath //kotlin/compiler:kotlin-compiler)", "-D@com_github_jetbrains_kotlin...kapt=$(rlocationpath //kotlin/compiler:kotlin-annotation-processing)", diff --git a/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt b/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt index 5f0d0f1af..776770584 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt +++ b/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt @@ -104,6 +104,27 @@ class KotlinToolchain private constructor( ).toPath() } + private val KOTLINX_SERIALIZATION_CORE_JVM by lazy { + BazelRunFiles + .resolveVerifiedFromProperty( + "@com_github_jetbrains_kotlinx...serialization-core-jvm", + ).toPath() + } + + private val KOTLINX_SERIALIZATION_JSON by lazy { + BazelRunFiles + .resolveVerifiedFromProperty( + "@com_github_jetbrains_kotlinx...serialization-json", + ).toPath() + } + + private val KOTLINX_SERIALIZATION_JSON_JVM by lazy { + BazelRunFiles + .resolveVerifiedFromProperty( + "@com_github_jetbrains_kotlinx...serialization-json-jvm", + ).toPath() + } + private val JAVA_HOME by lazy { FileSystems .getDefault() @@ -129,6 +150,9 @@ class KotlinToolchain private constructor( KAPT_PLUGIN.verified().absoluteFile, KSP_SYMBOL_PROCESSING_API.toFile(), KSP_SYMBOL_PROCESSING_CMDLINE.toFile(), + KOTLINX_SERIALIZATION_CORE_JVM.toFile(), + KOTLINX_SERIALIZATION_JSON.toFile(), + KOTLINX_SERIALIZATION_JSON_JVM.toFile(), ) @JvmStatic @@ -142,6 +166,9 @@ class KotlinToolchain private constructor( kaptFile: File, kspSymbolProcessingApi: File, kspSymbolProcessingCommandLine: File, + kotlinxSerializationCoreJvm: File, + kotlinxSerializationJson: File, + kotlinxSerializationJsonJvm: File, ): KotlinToolchain = KotlinToolchain( listOf( @@ -155,6 +182,9 @@ class KotlinToolchain private constructor( jdepsGenFile, kspSymbolProcessingApi, kspSymbolProcessingCommandLine, + kotlinxSerializationCoreJvm, + kotlinxSerializationJson, + kotlinxSerializationJsonJvm, ), jvmAbiGen = CompilerPlugin( diff --git a/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/ClassUsageRecorder.kt b/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/ClassUsageRecorder.kt index bd2cf5083..ac26e1039 100644 --- a/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/ClassUsageRecorder.kt +++ b/src/main/kotlin/io/bazel/kotlin/plugin/jdeps/k2/ClassUsageRecorder.kt @@ -44,13 +44,15 @@ class ClassUsageRecorder( visited: MutableSet