From 13de1ba418fb9f94dc4903c77141b76fc5f12714 Mon Sep 17 00:00:00 2001 From: Andrew Parmet Date: Mon, 27 May 2024 22:48:31 -0400 Subject: [PATCH] wip --- examples/grpc-node/build.gradle.kts | 37 ++++---- .../v1/codegen/generate/CodeGenerator.kt | 2 +- .../codegen/generate/DeserializerGenerator.kt | 6 +- .../v1/codegen/generate/EnumGenerator.kt | 3 +- .../v1/codegen/generate/MessageGenerator.kt | 3 +- .../v1/codegen/generate/ServiceGenerator.kt | 22 +++-- .../v1/codegen/util/GeneratorContext.kt | 2 +- .../util/GrpcKotlinGeneratorSupport.kt | 2 +- .../protokt/v1/codegen/util/PluginParams.kt | 16 ++-- .../protokt/v1/gradle/ProtoktExtension.kt | 2 +- .../protokt/v1/gradle/ProtobufBuild.kt | 7 +- .../protokt/v1/gradle/ProtoktBuild.kt | 84 +++++-------------- testing/protobufjs/build.gradle.kts | 12 ++- 13 files changed, 81 insertions(+), 117 deletions(-) diff --git a/examples/grpc-node/build.gradle.kts b/examples/grpc-node/build.gradle.kts index 7a718a1fd..ef5f5819b 100644 --- a/examples/grpc-node/build.gradle.kts +++ b/examples/grpc-node/build.gradle.kts @@ -13,12 +13,11 @@ * limitations under the License. */ -import com.google.protobuf.gradle.proto import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsExec import protokt.v1.gradle.protokt plugins { - id("org.jetbrains.kotlin.js") + id("org.jetbrains.kotlin.multiplatform") } kotlin { @@ -31,6 +30,23 @@ kotlin { binaries.executable() useCommonJs() } + + sourceSets { + val jsMain by getting { + dependencies { + api(project(":protokt-runtime-grpc-lite")) + api(project(":examples:protos")) + api(libs.kotlinx.coroutines.core) + } + } + + val jsTest by getting { + dependencies { + api(kotlin("test")) + api(libs.kotlinx.coroutines.test) + } + } + } } localProtokt() @@ -44,23 +60,6 @@ protokt { } } -dependencies { - implementation(project(":protokt-runtime-grpc-lite")) - implementation(project(":examples:protos")) - implementation(libs.kotlinx.coroutines.core) - - testImplementation(kotlin("test")) - testImplementation(libs.kotlinx.coroutines.test) -} - -sourceSets { - named("jsMain") { - proto { - srcDir("../protos/src/main/proto") - } - } -} - tasks.withType { args(listOfNotNull(properties["service"], properties["mode"], properties["args"])) } diff --git a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/CodeGenerator.kt b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/CodeGenerator.kt index 94c363818..0d7eb95d4 100644 --- a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/CodeGenerator.kt +++ b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/CodeGenerator.kt @@ -58,7 +58,7 @@ internal object CodeGenerator { generateService( type, ctx, - ctx.info.context.appliedKotlinPlugin + ctx.info.context.kotlinTarget ) } } diff --git a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/DeserializerGenerator.kt b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/DeserializerGenerator.kt index 20d596f92..084164b51 100644 --- a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/DeserializerGenerator.kt +++ b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/DeserializerGenerator.kt @@ -31,7 +31,7 @@ import protokt.v1.UnknownFieldSet import protokt.v1.codegen.generate.CodeGenerator.Context import protokt.v1.codegen.generate.Wrapper.interceptRead import protokt.v1.codegen.generate.Wrapper.wrapField -import protokt.v1.codegen.util.KotlinPlugin +import protokt.v1.codegen.util.KotlinTarget import protokt.v1.codegen.util.Message import protokt.v1.codegen.util.Oneof import protokt.v1.codegen.util.StandardField @@ -67,7 +67,7 @@ private class DeserializerGenerator( .addFunction( buildFunSpec("deserialize") { addModifiers(KModifier.OVERRIDE) - if (ctx.info.context.appliedKotlinPlugin != KotlinPlugin.JS) { + if (ctx.info.context.kotlinTarget != KotlinTarget.JS) { addAnnotation(JvmStatic::class) // can't put this here generally until JS code is actually common code in a multiplatform module } addParameter(READER, Reader::class) @@ -111,7 +111,7 @@ private class DeserializerGenerator( ) .addFunction( buildFunSpec("invoke") { - if (ctx.info.context.appliedKotlinPlugin != KotlinPlugin.JS) { + if (ctx.info.context.kotlinTarget != KotlinTarget.JS) { addAnnotation(JvmStatic::class) // todo: remove when JS code is common in multiplatform } addModifiers(KModifier.OPERATOR) diff --git a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/EnumGenerator.kt b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/EnumGenerator.kt index 337525291..5613da5d5 100644 --- a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/EnumGenerator.kt +++ b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/EnumGenerator.kt @@ -27,9 +27,10 @@ import protokt.v1.EnumReader import protokt.v1.codegen.generate.CodeGenerator.Context import protokt.v1.codegen.generate.Deprecation.handleDeprecation import protokt.v1.codegen.util.Enum +import protokt.v1.codegen.util.KotlinTarget internal fun generateEnum(e: Enum, ctx: Context) = - if (ctx.info.context.generateTypes) { + if (ctx.info.context.generateTypes && ctx.info.context.kotlinTarget == KotlinTarget.COMMON) { EnumGenerator(e, ctx).generate() } else { null diff --git a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/MessageGenerator.kt b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/MessageGenerator.kt index 625319cc7..5f84a6196 100644 --- a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/MessageGenerator.kt +++ b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/MessageGenerator.kt @@ -32,10 +32,11 @@ import protokt.v1.codegen.generate.CodeGenerator.Context import protokt.v1.codegen.generate.CodeGenerator.generate import protokt.v1.codegen.generate.Deprecation.handleDeprecation import protokt.v1.codegen.generate.Implements.handleSuperInterface +import protokt.v1.codegen.util.KotlinTarget import protokt.v1.codegen.util.Message internal fun generateMessage(msg: Message, ctx: Context) = - if (ctx.info.context.generateTypes) { + if (ctx.info.context.generateTypes && ctx.info.context.kotlinTarget == KotlinTarget.COMMON) { MessageGenerator(msg, ctx).generate() } else { null diff --git a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/ServiceGenerator.kt b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/ServiceGenerator.kt index 9b7e83c0b..f3d6f1c6c 100644 --- a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/ServiceGenerator.kt +++ b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/generate/ServiceGenerator.kt @@ -45,7 +45,7 @@ import io.grpc.kotlin.ClientCalls import io.grpc.kotlin.ServerCalls import kotlinx.coroutines.flow.Flow import protokt.v1.codegen.generate.CodeGenerator.Context -import protokt.v1.codegen.util.KotlinPlugin +import protokt.v1.codegen.util.KotlinTarget import protokt.v1.codegen.util.Method import protokt.v1.codegen.util.PROTOKT_V1_GOOGLE_PROTO import protokt.v1.codegen.util.Service @@ -57,13 +57,13 @@ import kotlin.reflect.KClass import kotlin.reflect.KFunction1 import kotlin.reflect.KFunction3 -internal fun generateService(s: Service, ctx: Context, kotlinPlugin: KotlinPlugin?) = - ServiceGenerator(s, ctx, kotlinPlugin).generate() +internal fun generateService(s: Service, ctx: Context, kotlinTarget: KotlinTarget?) = + ServiceGenerator(s, ctx, kotlinTarget).generate() private class ServiceGenerator( private val s: Service, private val ctx: Context, - private val kotlinPlugin: KotlinPlugin? + private val kotlinTarget: KotlinTarget? ) { fun generate(): List = (grpcImplementations() + serviceDescriptor()).filterNotNull() @@ -106,7 +106,7 @@ private class ServiceGenerator( } val grpcKtObject = - if (kotlinPlugin == KotlinPlugin.JS && ctx.info.context.generateGrpcKotlinStubs) { + if (kotlinTarget == KotlinTarget.JS && ctx.info.context.generateGrpcKotlinStubs) { val grpcKtClassName = ClassName(ctx.info.kotlinPackage, s.name + "GrpcKt") TypeSpec.objectBuilder(grpcKtClassName) .addType( @@ -404,9 +404,8 @@ private class ServiceGenerator( } private fun pivotClassName(jvmClass: KClass<*>) = - when (kotlinPlugin) { - KotlinPlugin.JS -> ClassName(KtMarshaller::class.java.`package`!!.name, jvmClass.asTypeName().simpleNames) - KotlinPlugin.MULTIPLATFORM -> error("unsupported plugin for service generation: $kotlinPlugin") + when (kotlinTarget) { + KotlinTarget.JS -> ClassName(KtMarshaller::class.java.`package`!!.name, jvmClass.asTypeName().simpleNames) else -> jvmClass.asTypeName() } @@ -416,15 +415,14 @@ private class ServiceGenerator( } private fun pivotPlugin(jvm: T, js: T) = - when (kotlinPlugin) { - KotlinPlugin.JS -> js - KotlinPlugin.MULTIPLATFORM -> error("unsupported plugin for service generation: $kotlinPlugin") + when (kotlinTarget) { + KotlinTarget.JS -> js else -> jvm } private fun FunSpec.Builder.staticIfAppropriate() = apply { - if (kotlinPlugin != KotlinPlugin.JS) { + if (kotlinTarget != KotlinTarget.JS) { addAnnotation(JvmStatic::class) } } diff --git a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/GeneratorContext.kt b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/GeneratorContext.kt index 8d82186fe..6b4087dc0 100644 --- a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/GeneratorContext.kt +++ b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/GeneratorContext.kt @@ -30,7 +30,7 @@ internal class GeneratorContext( val generateGrpcDescriptors = params.generateGrpcDescriptors val generateGrpcKotlinStubs = params.generateGrpcKotlinStubs val formatOutput = params.formatOutput - val appliedKotlinPlugin = params.appliedKotlinPlugin + val kotlinTarget = params.kotlinTarget val protoktVersion = PROTOKT_VERSION diff --git a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/GrpcKotlinGeneratorSupport.kt b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/GrpcKotlinGeneratorSupport.kt index 026a4d9bd..3b4c2a175 100644 --- a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/GrpcKotlinGeneratorSupport.kt +++ b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/GrpcKotlinGeneratorSupport.kt @@ -27,7 +27,7 @@ internal fun generateGrpcKotlinStubs( request: CodeGeneratorRequest ): List = if ( - params.appliedKotlinPlugin in setOf(KotlinPlugin.JVM, KotlinPlugin.ANDROID) && + params.kotlinTarget in setOf(KotlinTarget.JVM, KotlinTarget.ANDROID) && params.generateGrpcKotlinStubs ) { val out = ReadableByteArrayOutputStream() diff --git a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/PluginParams.kt b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/PluginParams.kt index 92e20728e..1c35f9e3e 100644 --- a/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/PluginParams.kt +++ b/protokt-codegen/src/main/kotlin/protokt/v1/codegen/util/PluginParams.kt @@ -17,7 +17,7 @@ package protokt.v1.codegen.util import com.google.common.base.CaseFormat import com.squareup.kotlinpoet.asClassName -import protokt.v1.gradle.APPLIED_KOTLIN_PLUGIN +import protokt.v1.gradle.KOTLIN_TARGET import protokt.v1.gradle.FORMAT_OUTPUT import protokt.v1.gradle.GENERATE_DESCRIPTORS import protokt.v1.gradle.GENERATE_GRPC_DESCRIPTORS @@ -45,7 +45,7 @@ internal class PluginParams( val generateGrpcDescriptors = params.getOrDefault(GENERATE_GRPC_DESCRIPTORS) val generateGrpcKotlinStubs = params.getOrDefault(GENERATE_GRPC_KOTLIN_STUBS) val formatOutput = params.getOrDefault(FORMAT_OUTPUT) - val appliedKotlinPlugin = params[APPLIED_KOTLIN_PLUGIN]?.toKotlinPluginEnum() + val kotlinTarget = params[KOTLIN_TARGET]?.toKotlinPluginEnum() } private inline fun Map.getOrDefault(key: String): Boolean { @@ -74,15 +74,15 @@ private inline fun Map.getOrDefault(key: String): Bo private fun String.toKotlinPluginEnum() = when (this) { - "org.jetbrains.kotlin.multiplatform" -> KotlinPlugin.MULTIPLATFORM - "org.jetbrains.kotlin.js" -> KotlinPlugin.JS - "org.jetbrains.kotlin.jvm" -> KotlinPlugin.JVM - "org.jetbrains.kotlin.android" -> KotlinPlugin.ANDROID + "common" -> KotlinTarget.COMMON + "js" -> KotlinTarget.JS + "jvm" -> KotlinTarget.JVM + "android" -> KotlinTarget.ANDROID else -> null } -enum class KotlinPlugin { - MULTIPLATFORM, +enum class KotlinTarget { + COMMON, JS, JVM, ANDROID diff --git a/shared-src/codegen/protokt/v1/gradle/ProtoktExtension.kt b/shared-src/codegen/protokt/v1/gradle/ProtoktExtension.kt index 6e6eb4324..60167e1f3 100644 --- a/shared-src/codegen/protokt/v1/gradle/ProtoktExtension.kt +++ b/shared-src/codegen/protokt/v1/gradle/ProtoktExtension.kt @@ -21,7 +21,7 @@ const val GENERATE_DESCRIPTORS = "generate_descriptors" const val GENERATE_GRPC_DESCRIPTORS = "generate_grpc_descriptors" const val GENERATE_GRPC_KOTLIN_STUBS = "generate_grpc_kotlin_stubs" const val FORMAT_OUTPUT = "format_output" -const val APPLIED_KOTLIN_PLUGIN = "applied_kotlin_plugin" +const val KOTLIN_TARGET = "kotlin_target" open class ProtoktExtension { /** diff --git a/shared-src/gradle-plugin/protokt/v1/gradle/ProtobufBuild.kt b/shared-src/gradle-plugin/protokt/v1/gradle/ProtobufBuild.kt index e5c8dd8ae..18ecf3663 100644 --- a/shared-src/gradle-plugin/protokt/v1/gradle/ProtobufBuild.kt +++ b/shared-src/gradle-plugin/protokt/v1/gradle/ProtobufBuild.kt @@ -34,6 +34,7 @@ internal fun configureProtobufPlugin( project: Project, ext: ProtoktExtension, disableJava: Boolean, + target: String, binaryPath: String ) { project.apply() @@ -46,7 +47,7 @@ internal fun configureProtobufPlugin( } plugins { - id("protokt") { + id("protokt-$target") { path = normalizePath(binaryPath) } } @@ -60,7 +61,7 @@ internal fun configureProtobufPlugin( } task.plugins { - id("protokt") { + id("protokt-$target") { project.afterEvaluate { option("$KOTLIN_EXTRA_CLASSPATH=${extraClasspath(project, task)}") option("$GENERATE_TYPES=${ext.generate.types}") @@ -68,7 +69,7 @@ internal fun configureProtobufPlugin( option("$GENERATE_GRPC_DESCRIPTORS=${ext.generate.grpcDescriptors}") option("$GENERATE_GRPC_KOTLIN_STUBS=${ext.generate.grpcKotlinStubs}") option("$FORMAT_OUTPUT=${ext.formatOutput}") - option("$APPLIED_KOTLIN_PLUGIN=${project.appliedKotlinPlugin()}") + option("$KOTLIN_TARGET=$target") } } } diff --git a/shared-src/gradle-plugin/protokt/v1/gradle/ProtoktBuild.kt b/shared-src/gradle-plugin/protokt/v1/gradle/ProtoktBuild.kt index 11f032d70..b52cee0de 100644 --- a/shared-src/gradle-plugin/protokt/v1/gradle/ProtoktBuild.kt +++ b/shared-src/gradle-plugin/protokt/v1/gradle/ProtoktBuild.kt @@ -37,7 +37,9 @@ import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension +import org.jetbrains.kotlin.gradle.dsl.kotlinExtension import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet +import org.jetbrains.kotlin.gradle.plugin.mpp.pm20.util.targets import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet import org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile import kotlin.reflect.KClass @@ -55,10 +57,8 @@ internal fun configureProtokt( resolveBinary: () -> String ) { injectKotlinPluginsIntoProtobufGradle() - val ext = project.extensions.create("protokt") - configureProtobufPlugin(project, ext, disableJava, resolveBinary()) - project.createExtensionConfigurationsAndConfigureProtobuf() + project.createExtensionConfigurationsAndConfigureProtobuf(disableJava, resolveBinary) // must wait for extension to resolve project.afterEvaluate { @@ -75,10 +75,14 @@ private fun injectKotlinPluginsIntoProtobufGradle() { @Suppress("UNCHECKED_CAST") val prerequisitePlugins = prerequisitePluginsField.get(null) as MutableList prerequisitePlugins.add("org.jetbrains.kotlin.multiplatform") - prerequisitePlugins.add("org.jetbrains.kotlin.js") } -private fun Project.createExtensionConfigurationsAndConfigureProtobuf() { +private fun Project.createExtensionConfigurationsAndConfigureProtobuf( + disableJava: Boolean, + resolveBinary: () -> String +) { + val ext = extensions.create("protokt") + val extensionsConfiguration = configurations.create(EXTENSIONS) val testExtensionsConfiguration = configurations.create(TEST_EXTENSIONS) @@ -95,17 +99,17 @@ private fun Project.createExtensionConfigurationsAndConfigureProtobuf() { } pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { - configureProtoktConfigurations(KotlinMultiplatformExtension::class, "commonMain", "commonTest") + configureProtobufPlugin(project, ext, disableJava, "common", resolveBinary()) linkGenerateProtoToSourceCompileForKotlinMpp("commonMain", "commonTest") - } - - pluginManager.withPlugin("org.jetbrains.kotlin.js") { - configureProtoktConfigurations(KotlinJsProjectExtension::class, "main", "test") - val (mainSourceSetName, testSourceSetName) = configureJs() - // hacking into hack configurations owned by protobbuf-gradle-plugin - configurations.getByName("${mainSourceSetName}CompileProtoPath").extendsFrom(extensionsConfiguration) - configurations.getByName("${testSourceSetName}CompileProtoPath").extendsFrom(testExtensionsConfiguration) + kotlinExtension + .targets + .filterNot { it.targetName == "metadata" } + .forEach { + configureProtobufPlugin(project, ext, disableJava, it.targetName, resolveBinary()) + configureProtoktConfigurations(KotlinMultiplatformExtension::class, "${it.targetName}Main", "${it.targetName}Test") + linkGenerateProtoToSourceCompileForKotlinMpp("${it.targetName}Main", "${it.targetName}Test") + } } val otherwise = { @@ -114,10 +118,12 @@ private fun Project.createExtensionConfigurationsAndConfigureProtobuf() { } pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + configureProtobufPlugin(project, ext, disableJava, "jvm", resolveBinary()) otherwise() } pluginManager.withPlugin("org.jetbrains.kotlin.android") { + configureProtobufPlugin(project, ext, disableJava, "jvm", resolveBinary()) otherwise() } } @@ -147,6 +153,7 @@ private fun Project.linkGenerateProtoTasksAndIncludeGeneratedSource(sourceSetNam } } +// todo: this pattern isn't right. grab proto tasks for each target and add the source directory sets directly. private fun Project.configureSourceSets( sourceSetName: String, protoSourceSetRoot: String, @@ -177,42 +184,6 @@ private fun GenerateProtoTask.buildSourceDirectorySet(): SourceDirectorySet { return srcSet } -// The Kotlin JS plugin doesn't create main or test source sets -private fun Project.configureJs(): Pair { - // Can't call them "main" and "test" otherwise we'll get conflicting tasks 'processResources' and 'testClasses' - val mainSourceSet = the().create("jsMain") - val testSourceSet = the().create("jsTest") - - val extension = project.extensions.getByType() - - fun linkGenerateProtoTasksAndIncludeGeneratedSource(sourceSet: SourceSet, test: Boolean) { - val targetSourceSetName = if (test) "test" else "main" - - extension.generateProtoTasks.ofSourceSet(sourceSet.name).forEach { genProtoTask -> - configureSourceSets(targetSourceSetName, sourceSet.name, genProtoTask) - the().getByName(sourceSet.name).proto { srcDir("src/$targetSourceSetName/proto") } - tasks.withType> { - if ((test && name.contains("Test")) || (!test && !name.contains("Test"))) { - dependsOn(genProtoTask) - } - } - } - } - - linkGenerateProtoTasksAndIncludeGeneratedSource(mainSourceSet, false) - linkGenerateProtoTasksAndIncludeGeneratedSource(testSourceSet, true) - - tasks.withType { - from(fileTree("${layout.buildDirectory.get()}/extracted-protos/${mainSourceSet.name}")) - duplicatesStrategy = DuplicatesStrategy.EXCLUDE // TODO: figure out how to get rid of this - } - - tasks.register("generateProto") { dependsOn("generateJsMainProto") } - tasks.register("generateTestProto") { dependsOn("generateJsTestProto") } - - return mainSourceSet.name to testSourceSet.name -} - internal fun Project.resolveProtoktCoreDep(protoktVersion: Any?): Dependency? { if (name in setOf("protokt-core", "protokt-core-lite")) { return null @@ -231,16 +202,3 @@ internal fun Project.resolveProtoktCoreDep(protoktVersion: Any?): Dependency? { dependencies.create("com.toasttab.protokt:$artifactId:$protoktVersion") } } - -internal fun Project.appliedKotlinPlugin() = - when { - plugins.hasPlugin("org.jetbrains.kotlin.multiplatform") -> - "org.jetbrains.kotlin.multiplatform" - plugins.hasPlugin("org.jetbrains.kotlin.js") -> - "org.jetbrains.kotlin.js" - plugins.hasPlugin("org.jetbrains.kotlin.jvm") -> - "org.jetbrains.kotlin.jvm" - plugins.hasPlugin("org.jetbrains.kotlin.android") -> - "org.jetbrains.kotlin.android" - else -> null - } diff --git a/testing/protobufjs/build.gradle.kts b/testing/protobufjs/build.gradle.kts index 532b57870..fa3d89ce4 100644 --- a/testing/protobufjs/build.gradle.kts +++ b/testing/protobufjs/build.gradle.kts @@ -16,17 +16,23 @@ import protokt.v1.gradle.protoktExtensions plugins { - id("org.jetbrains.kotlin.js") + id("org.jetbrains.kotlin.multiplatform") } kotlin { js(IR) { configureJsTests() } + + sourceSets { + val jsTest by getting { + dependencies { + api(kotlin("test")) + } + } + } } localProtokt() dependencies { protoktExtensions(project(":extensions:protokt-extensions")) - - testImplementation(kotlin("test")) }