diff --git a/MODULE.bazel b/MODULE.bazel index 4d9865fc8..40af3bee4 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -29,6 +29,7 @@ use_repo( "com_github_jetbrains_kotlin", "com_github_jetbrains_kotlin_git", "com_github_pinterest_ktlint", + "kotlin_build_tools_impl", "kotlinx_serialization_core_jvm", "kotlinx_serialization_json", "kotlinx_serialization_json_jvm", diff --git a/MODULE.release.bazel b/MODULE.release.bazel index f7a6d8aa1..2968296d8 100644 --- a/MODULE.release.bazel +++ b/MODULE.release.bazel @@ -30,6 +30,7 @@ use_repo( "kotlinx_serialization_core_jvm", "kotlinx_serialization_json", "kotlinx_serialization_json_jvm", + "kotlin_build_tools_impl", ) register_toolchains("//kotlin/internal:default_toolchain") diff --git a/docs/kotlin.md b/docs/kotlin.md index 7fdb2aeb5..35bbdd36d 100755 --- a/docs/kotlin.md +++ b/docs/kotlin.md @@ -515,9 +515,9 @@ define_kt_toolchain(name, experimental_treat_internal_as_private_in_abi_jars, experimental_remove_private_classes_in_abi_jars, experimental_strict_kotlin_deps, experimental_report_unused_deps, experimental_reduce_classpath_mode, - experimental_multiplex_workers, javac_options, kotlinc_options, jvm_stdlibs, - jvm_runtime, jacocorunner, exec_compatible_with, target_compatible_with, - target_settings) + experimental_multiplex_workers, experimental_build_tools_api, javac_options, + kotlinc_options, jvm_stdlibs, jvm_runtime, jacocorunner, exec_compatible_with, + target_compatible_with, target_settings) Define the Kotlin toolchain. @@ -538,6 +538,7 @@ Define the Kotlin toolchain. | experimental_report_unused_deps |

-

| `None` | | experimental_reduce_classpath_mode |

-

| `None` | | experimental_multiplex_workers |

-

| `None` | +| experimental_build_tools_api |

-

| `None` | | javac_options |

-

| `Label("@rules_kotlin//kotlin/internal:default_javac_options")` | | kotlinc_options |

-

| `Label("@rules_kotlin//kotlin/internal:default_kotlinc_options")` | | jvm_stdlibs |

-

| `None` | diff --git a/kotlin/internal/jvm/compile.bzl b/kotlin/internal/jvm/compile.bzl index 4d41ab1f2..b501bbca0 100644 --- a/kotlin/internal/jvm/compile.bzl +++ b/kotlin/internal/jvm/compile.bzl @@ -462,6 +462,7 @@ def _run_kt_builder_action( args.add("--strict_kotlin_deps", toolchains.kt.experimental_strict_kotlin_deps) args.add_all("--classpath", compile_deps.compile_jars) args.add("--reduced_classpath_mode", toolchains.kt.experimental_reduce_classpath_mode) + args.add("--build_tools_api", toolchains.kt.experimental_build_tools_api) args.add_all("--sources", srcs.all_srcs, omit_if_empty = True) args.add_all("--source_jars", srcs.src_jars + generated_src_jars, omit_if_empty = True) args.add_all("--deps_artifacts", deps_artifacts, omit_if_empty = True) diff --git a/kotlin/internal/toolchains.bzl b/kotlin/internal/toolchains.bzl index 77ae63080..44a16075b 100644 --- a/kotlin/internal/toolchains.bzl +++ b/kotlin/internal/toolchains.bzl @@ -91,6 +91,7 @@ def _kotlin_toolchain_impl(ctx): experimental_strict_kotlin_deps = ctx.attr.experimental_strict_kotlin_deps, experimental_report_unused_deps = ctx.attr.experimental_report_unused_deps, experimental_reduce_classpath_mode = ctx.attr.experimental_reduce_classpath_mode, + experimental_build_tools_api = ctx.attr.experimental_build_tools_api, javac_options = ctx.attr.javac_options[JavacOptions] if ctx.attr.javac_options else None, kotlinc_options = ctx.attr.kotlinc_options[KotlincOptions] if ctx.attr.kotlinc_options else None, empty_jar = ctx.file._empty_jar, @@ -247,6 +248,10 @@ _kt_toolchain = rule( "KOTLINBUILDER_REDUCED", ], ), + "experimental_build_tools_api": attr.bool( + doc = "Enables experimental support for Build Tools API integration", + default = False, + ), "javac_options": attr.label( doc = "Compiler options for javac", providers = [JavacOptions], @@ -321,6 +326,7 @@ def define_kt_toolchain( experimental_report_unused_deps = None, experimental_reduce_classpath_mode = None, experimental_multiplex_workers = None, + experimental_build_tools_api = None, javac_options = Label("//kotlin/internal:default_javac_options"), kotlinc_options = Label("//kotlin/internal:default_kotlinc_options"), jvm_stdlibs = None, @@ -349,6 +355,7 @@ def define_kt_toolchain( experimental_strict_kotlin_deps = experimental_strict_kotlin_deps, experimental_report_unused_deps = experimental_report_unused_deps, experimental_reduce_classpath_mode = experimental_reduce_classpath_mode, + experimental_build_tools_api = experimental_build_tools_api, javac_options = javac_options, kotlinc_options = kotlinc_options, visibility = ["//visibility:public"], diff --git a/kotlin/settings/BUILD.bazel b/kotlin/settings/BUILD.bazel index c541d5a53..15bca687f 100644 --- a/kotlin/settings/BUILD.bazel +++ b/kotlin/settings/BUILD.bazel @@ -42,3 +42,9 @@ bool_flag( build_setting_default = False, visibility = ["//visibility:public"], ) + +bool_flag( + name = "experimental_build_tools_api", + build_setting_default = False, + visibility = ["//visibility:public"], +) diff --git a/kotlin/settings/BUILD.release.bazel b/kotlin/settings/BUILD.release.bazel index ce00fcf2b..a36d5fffe 100644 --- a/kotlin/settings/BUILD.release.bazel +++ b/kotlin/settings/BUILD.release.bazel @@ -33,3 +33,10 @@ bool_flag( build_setting_default = False, visibility = ["//visibility:public"], ) + +# --@rules_kotlin//kotlin/settings:experimental_build_tools_api=True +bool_flag( + name = "experimental_build_tools_api", + build_setting_default = False, + visibility = ["//visibility:public"], +) diff --git a/src/main/kotlin/BUILD.release.bazel b/src/main/kotlin/BUILD.release.bazel index 2c4c90706..2211fe94b 100644 --- a/src/main/kotlin/BUILD.release.bazel +++ b/src/main/kotlin/BUILD.release.bazel @@ -47,6 +47,7 @@ java_binary( "//kotlin/compiler:symbol-processing-cmdline", "//src/main/kotlin/io/bazel/kotlin/compiler", "@com_github_jetbrains_kotlin//:home", + "@kotlin_build_tools_impl//jar", "@kotlinx_serialization_core_jvm//jar", "@kotlinx_serialization_json//jar", "@kotlinx_serialization_json_jvm//jar", @@ -55,6 +56,7 @@ java_binary( "-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...build-tools-impl=$(rlocationpath @kotlin_build_tools_impl//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 3b340e935..98511d7b3 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/cmd/BUILD.bazel +++ b/src/main/kotlin/io/bazel/kotlin/builder/cmd/BUILD.bazel @@ -26,6 +26,7 @@ kt_bootstrap_binary( "//src/main/kotlin:skip-code-gen", "//src/main/kotlin/io/bazel/kotlin/compiler:compiler.jar", "@com_github_jetbrains_kotlin//:home", + "@kotlin_build_tools_impl//jar", "@kotlinx_serialization_core_jvm//jar", "@kotlinx_serialization_json//jar", "@kotlinx_serialization_json_jvm//jar", @@ -34,6 +35,7 @@ kt_bootstrap_binary( "-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...build-tools-impl=$(rlocationpath @kotlin_build_tools_impl//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/tasks/KotlinBuilder.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt index 8e2edc497..e8bb03370 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt +++ b/src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt @@ -87,6 +87,7 @@ class KotlinBuilder REDUCED_CLASSPATH_MODE("--reduced_classpath_mode"), INSTRUMENT_COVERAGE("--instrument_coverage"), KSP_GENERATED_JAVA_SRCJAR("--ksp_generated_java_srcjar"), + BUILD_TOOLS_API("--build_tools_api"), } } @@ -169,6 +170,9 @@ class KotlinBuilder argMap.optionalSingle(KotlinBuilderFlags.ABI_JAR_REMOVE_PRIVATE_CLASSES)?.let { removePrivateClassesInAbiJar = it == "true" } + argMap.optionalSingle(KotlinBuilderFlags.BUILD_TOOLS_API)?.let { + buildToolsApi = it == "true" + } this } diff --git a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt index 7250155a7..ef379d842 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt +++ b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt @@ -33,7 +33,7 @@ const val X_FRIENDS_PATH_SEPARATOR = "," class KotlinJvmTaskExecutor @Inject internal constructor( - private val compiler: KotlinToolchain.KotlincInvoker, + private val compilerBuilder: KotlinToolchain.KotlincInvokerBuilder, private val plugins: InternalCompilerPlugins, ) { private fun combine( @@ -54,6 +54,8 @@ class KotlinJvmTaskExecutor context: CompilationTaskContext, task: JvmCompilationTask, ) { + val compiler = compilerBuilder.build(context.info.buildToolsApi) + val preprocessedTask = task .preProcessingSteps(context) 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 776770584..d5ed414cf 100644 --- a/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt +++ b/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt @@ -125,6 +125,13 @@ class KotlinToolchain private constructor( ).toPath() } + private val BUILD_TOOLS_API by lazy { + BazelRunFiles + .resolveVerifiedFromProperty( + "@com_github_jetbrains_kotlin...build-tools-impl", + ).toPath() + } + private val JAVA_HOME by lazy { FileSystems .getDefault() @@ -144,6 +151,7 @@ class KotlinToolchain private constructor( JAVA_HOME, KOTLINC.verified().absoluteFile, COMPILER.verified().absoluteFile, + BUILD_TOOLS_API.verified().absoluteFile, JVM_ABI_PLUGIN.verified().absoluteFile, SKIP_CODE_GEN_PLUGIN.verified().absoluteFile, JDEPS_GEN_PLUGIN.verified().absoluteFile, @@ -159,6 +167,7 @@ class KotlinToolchain private constructor( fun createToolchain( javaHome: Path, kotlinc: File, + buildTools: File, compiler: File, jvmAbiGenFile: File, skipCodeGenFile: File, @@ -174,6 +183,7 @@ class KotlinToolchain private constructor( listOf( kotlinc, compiler, + buildTools, // plugins *must* be preloaded. Not doing so causes class conflicts // (and a NoClassDef err) in the compiler extension interfaces. // This may cause issues in accepting user defined compiler plugins. @@ -263,7 +273,7 @@ class KotlinToolchain private constructor( val id: String, ) - open class KotlinCliToolInvoker internal constructor( + open class KotlincInvoker internal constructor( toolchain: KotlinToolchain, clazz: String, ) { @@ -296,12 +306,19 @@ class KotlinToolchain private constructor( } @Singleton - class KotlincInvoker + class KotlincInvokerBuilder @Inject constructor( - toolchain: KotlinToolchain, - ) : KotlinCliToolInvoker( - toolchain.toolchainWithReflect(), - "io.bazel.kotlin.compiler.BazelK2JVMCompiler", - ) + private val toolchain: KotlinToolchain, + ) { + fun build(useExperimentalBuildToolsAPI: Boolean): KotlincInvoker { + val clazz = + if (useExperimentalBuildToolsAPI) { + "io.bazel.kotlin.compiler.BuildToolsAPICompiler" + } else { + "io.bazel.kotlin.compiler.BazelK2JVMCompiler" + } + return KotlincInvoker(toolchain = toolchain, clazz = clazz) + } + } } diff --git a/src/main/kotlin/io/bazel/kotlin/compiler/BuildToolsAPICompiler.kt b/src/main/kotlin/io/bazel/kotlin/compiler/BuildToolsAPICompiler.kt new file mode 100644 index 000000000..0a2472c9c --- /dev/null +++ b/src/main/kotlin/io/bazel/kotlin/compiler/BuildToolsAPICompiler.kt @@ -0,0 +1,60 @@ +/* + * Copyright 2025 The Bazel Authors. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.bazel.kotlin.compiler + +import org.jetbrains.kotlin.buildtools.api.CompilationResult +import org.jetbrains.kotlin.buildtools.api.CompilationService +import org.jetbrains.kotlin.buildtools.api.ExperimentalBuildToolsApi +import org.jetbrains.kotlin.buildtools.api.ProjectId +import org.jetbrains.kotlin.cli.common.ExitCode +import java.util.UUID + +@Suppress("unused") +class BuildToolsAPICompiler { + @OptIn(ExperimentalBuildToolsApi::class) + fun exec( + errStream: java.io.PrintStream, + vararg args: String, + ): ExitCode { + System.setProperty("zip.handler.uses.crc.instead.of.timestamp", "true") + + val kotlinService = CompilationService.loadImplementation(this.javaClass.classLoader!!) + // The execution configuration. Controls in-process vs daemon execution strategies. Default is in-process. + val executionConfig = kotlinService.makeCompilerExecutionStrategyConfiguration() + // The compilation configuration. Controls everything related to incremental compilation. + val compilationConfig = + kotlinService.makeJvmCompilationConfiguration().apply { + // useLogger(BasicKotlinLogger(true, "/tmp/kotlin_log/$label.log")) + } + + val result = + kotlinService.compileJvm( + ProjectId.ProjectUUID(UUID.randomUUID()), + executionConfig, + compilationConfig, + emptyList(), + args.toList(), + ) + + // BTAPI returns a different type than K2JVMCompiler (CompilationResult vs ExitCode). + return when (result) { + CompilationResult.COMPILATION_SUCCESS -> ExitCode.OK + CompilationResult.COMPILATION_ERROR -> ExitCode.COMPILATION_ERROR + CompilationResult.COMPILATION_OOM_ERROR -> ExitCode.OOM_ERROR + CompilationResult.COMPILER_INTERNAL_ERROR -> ExitCode.INTERNAL_ERROR + } + } +} diff --git a/src/main/kotlin/io/bazel/kotlin/test/BazelIntegrationTestRunner.kt b/src/main/kotlin/io/bazel/kotlin/test/BazelIntegrationTestRunner.kt index 5a76eb194..04a171716 100644 --- a/src/main/kotlin/io/bazel/kotlin/test/BazelIntegrationTestRunner.kt +++ b/src/main/kotlin/io/bazel/kotlin/test/BazelIntegrationTestRunner.kt @@ -59,64 +59,69 @@ object BazelIntegrationTestRunner { listOf(true, false).filter { bzlmod -> bzlmod && workspace.hasModule() || !bzlmod && workspace.hasWorkspace() }.forEach { bzlmod -> - println("Starting bzlmod $bzlmod test") - val overrideFlag = if (bzlmod) "--override_module=rules_kotlin=$unpack" else "--override_repository=rules_kotlin=$unpack" - bazel.run( - workspace, - "--bazelrc=$bazelrc", - "clean", - "--expunge", - "--async" - ).onFailThrow() - bazel.run( - workspace, - "--bazelrc=$bazelrc", - "shutdown", - ).onFailThrow() - bazel.run( - workspace, - "--bazelrc=$bazelrc", - "info", - *version.workspaceFlag(bzlmod), - overrideFlag - ).onFailThrow() - bazel.run( - workspace, - "--bazelrc=$bazelrc", - "build", - overrideFlag, - "--incompatible_disallow_empty_glob=false", - "//...", - *version.workspaceFlag(bzlmod) - ).onFailThrow() - bazel.run( - workspace, - "--bazelrc=$bazelrc", - "query", - overrideFlag, - "--incompatible_disallow_empty_glob=false", - "@rules_kotlin//...", - *version.workspaceFlag(bzlmod) - ).onFailThrow() - bazel.run( - workspace, - "--bazelrc=$bazelrc", - "query", - *version.workspaceFlag(bzlmod), - overrideFlag, - "--incompatible_disallow_empty_glob=false", - "kind(\".*_test\", \"//...\")", - ).ok { process -> - if (process.stdOut.isNotEmpty()) { - bazel.run( - workspace, - "--bazelrc=$bazelrc", - "test", - *version.workspaceFlag(bzlmod), - overrideFlag, - "--test_output=all", - "//...", - ).onFailThrow() + listOf(true, false).forEach { buildToolsApi -> + println("Starting bzlmod $bzlmod test") + val overrideFlag = + if (bzlmod) "--override_module=rules_kotlin=$unpack" else "--override_repository=rules_kotlin=$unpack" + bazel.run( + workspace, + "--bazelrc=$bazelrc", + "clean", + "--expunge", + "--async", + ).onFailThrow() + bazel.run( + workspace, + "--bazelrc=$bazelrc", + "shutdown", + ).onFailThrow() + bazel.run( + workspace, + "--bazelrc=$bazelrc", + "info", + *version.workspaceFlag(bzlmod), + overrideFlag, + ).onFailThrow() + bazel.run( + workspace, + "--bazelrc=$bazelrc", + "build", + overrideFlag, + "--incompatible_disallow_empty_glob=false", + "--@rules_kotlin//kotlin/settings:experimental_build_tools_api=${buildToolsApi}", + "//...", + *version.workspaceFlag(bzlmod), + ).onFailThrow() + bazel.run( + workspace, + "--bazelrc=$bazelrc", + "query", + overrideFlag, + "--incompatible_disallow_empty_glob=false", + "@rules_kotlin//...", + *version.workspaceFlag(bzlmod), + ).onFailThrow() + bazel.run( + workspace, + "--bazelrc=$bazelrc", + "query", + *version.workspaceFlag(bzlmod), + overrideFlag, + "--incompatible_disallow_empty_glob=false", + "kind(\".*_test\", \"//...\")", + ).ok { process -> + if (process.stdOut.isNotEmpty()) { + bazel.run( + workspace, + "--bazelrc=$bazelrc", + "test", + *version.workspaceFlag(bzlmod), + overrideFlag, + "--@rules_kotlin//kotlin/settings:experimental_build_tools_api=${buildToolsApi}", + "--test_output=all", + "//...", + ).onFailThrow() + } } } } diff --git a/src/main/protobuf/kotlin_model.proto b/src/main/protobuf/kotlin_model.proto index d39548e5f..60399bf1e 100644 --- a/src/main/protobuf/kotlin_model.proto +++ b/src/main/protobuf/kotlin_model.proto @@ -85,6 +85,8 @@ message CompilationTaskInfo { bool treat_internal_as_private_in_abi_jar = 12; // Private classes are removed in abi.jar generation bool remove_private_classes_in_abi_jar = 13; + // New Build Tools API. Required for incremental compilation. + bool build_tools_api = 14; } // Nested messages not marked with stable could be refactored. diff --git a/src/main/starlark/core/repositories/initialize.release.bzl b/src/main/starlark/core/repositories/initialize.release.bzl index 5a7368841..f834c95cc 100644 --- a/src/main/starlark/core/repositories/initialize.release.bzl +++ b/src/main/starlark/core/repositories/initialize.release.bzl @@ -93,6 +93,13 @@ def kotlin_repositories( urls = [url.format(version = versions.KOTLINX_SERIALIZATION_JSON_JVM.version) for url in versions.KOTLINX_SERIALIZATION_JSON_JVM.url_templates], ) + maybe( + http_jar, + name = "kotlin_build_tools_impl", + sha256 = versions.KOTLIN_BUILD_TOOLS_IMPL.sha256, + urls = [url.format(version = versions.KOTLIN_BUILD_TOOLS_IMPL.version) for url in versions.KOTLIN_BUILD_TOOLS_IMPL.url_templates], + ) + if is_bzlmod: return diff --git a/src/main/starlark/core/repositories/versions.bzl b/src/main/starlark/core/repositories/versions.bzl index 9e07ac8ff..814ae02b5 100644 --- a/src/main/starlark/core/repositories/versions.bzl +++ b/src/main/starlark/core/repositories/versions.bzl @@ -87,6 +87,13 @@ versions = struct( ], sha256 = "44e965bb067b2bb5cd9184dab2c3dea6e3eab747d341c07645bb4c88f09e49c8", ), + KOTLIN_BUILD_TOOLS_IMPL = version( + version = "2.1.20", + url_templates = [ + "https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-build-tools-impl/{version}/kotlin-build-tools-impl-{version}.jar", + ], + sha256 = "6e94896e321603e3bfe89fef02478e44d1d64a3d25d49d0694892ffc01c60acf", + ), RULES_ANDROID = version( version = "0.6.4", url_templates = [ diff --git a/src/test/kotlin/io/bazel/kotlin/builder/KotlinAbstractTestBuilder.java b/src/test/kotlin/io/bazel/kotlin/builder/KotlinAbstractTestBuilder.java index c98a780b3..ff2292288 100644 --- a/src/test/kotlin/io/bazel/kotlin/builder/KotlinAbstractTestBuilder.java +++ b/src/test/kotlin/io/bazel/kotlin/builder/KotlinAbstractTestBuilder.java @@ -235,6 +235,7 @@ static KotlinToolchain toolchainForTest() { return KotlinToolchain.createToolchain( javaHome, new File(Deps.Dep.fromLabel("//kotlin/compiler:kotlin-compiler").singleCompileJar()), + new File(Deps.Dep.fromLabel("@kotlin_build_tools_impl//jar").singleCompileJar()), new File(Deps.Dep.fromLabel("//src/main/kotlin/io/bazel/kotlin/compiler:compiler.jar").singleCompileJar()), new File(Deps.Dep.fromLabel("//kotlin/compiler:jvm-abi-gen").singleCompileJar()), new File(Deps.Dep.fromLabel("//src/main/kotlin:skip-code-gen").singleCompileJar()), diff --git a/src/test/kotlin/io/bazel/kotlin/defs.bzl b/src/test/kotlin/io/bazel/kotlin/defs.bzl index 7f914191e..fe5e2111c 100644 --- a/src/test/kotlin/io/bazel/kotlin/defs.bzl +++ b/src/test/kotlin/io/bazel/kotlin/defs.bzl @@ -47,6 +47,7 @@ def kt_rules_test(name, **kwargs): "@kotlinx_serialization_core_jvm//jar", "@kotlinx_serialization_json//jar", "@kotlinx_serialization_json_jvm//jar", + "@kotlin_build_tools_impl//jar", ] + args["data"]: if dep not in args["data"]: args["data"].append(dep)