diff --git a/.gitignore b/.gitignore index f769ce1d76..2bf071913b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ reports jacoco.exec .externalNativeBuild .cxx +.kotlin # iOS *.pbxuser diff --git a/build.gradle.kts b/build.gradle.kts index 3baac810de..89db5f162d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -167,7 +167,7 @@ allprojects { repositories { maven { name = "testMaven" - url = file("${rootProject.buildDir}/testMaven").toURI() + url = rootProject.layout.buildDirectory.dir("testMaven").get().asFile.toURI() } /* diff --git a/zipline-bytecode/src/test/kotlin/app/cash/zipline/bytecode/ApplySourceMapToBytecodeTest.kt b/zipline-bytecode/src/test/kotlin/app/cash/zipline/bytecode/ApplySourceMapToBytecodeTest.kt index eca19a2a98..4db9c472d2 100644 --- a/zipline-bytecode/src/test/kotlin/app/cash/zipline/bytecode/ApplySourceMapToBytecodeTest.kt +++ b/zipline-bytecode/src/test/kotlin/app/cash/zipline/bytecode/ApplySourceMapToBytecodeTest.kt @@ -40,7 +40,7 @@ class ApplySourceMapToBytecodeTest { ) @Before - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. fun setUp() { // Configure QuickJS to support module loading. app.cash.zipline.internal.initModuleLoader(quickJs) @@ -222,7 +222,7 @@ class ApplySourceMapToBytecodeTest { assertThat(quickJs.evaluate("doubleToDisplayString('1000.0')")).isEqualTo("1000.0") } - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. private fun loadJsModule(id: String, bytecode: ByteArray) { app.cash.zipline.internal.loadJsModule(quickJs, id, bytecode) } diff --git a/zipline-cli/src/main/kotlin/app/cash/zipline/cli/GenerateKeyPair.kt b/zipline-cli/src/main/kotlin/app/cash/zipline/cli/GenerateKeyPair.kt index f84504339c..07408aad99 100644 --- a/zipline-cli/src/main/kotlin/app/cash/zipline/cli/GenerateKeyPair.kt +++ b/zipline-cli/src/main/kotlin/app/cash/zipline/cli/GenerateKeyPair.kt @@ -33,7 +33,7 @@ class GenerateKeyPair( .default(Ed25519) .help("Signing algorithm to use.") - @Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals. override fun run() { val keyPair = app.cash.zipline.loader.internal.generateKeyPair(algorithm) out.println( diff --git a/zipline-cli/src/test/kotlin/app/cash/zipline/cli/DownloadTest.kt b/zipline-cli/src/test/kotlin/app/cash/zipline/cli/DownloadTest.kt index 65feb414e3..fa0a5aab8f 100644 --- a/zipline-cli/src/test/kotlin/app/cash/zipline/cli/DownloadTest.kt +++ b/zipline-cli/src/test/kotlin/app/cash/zipline/cli/DownloadTest.kt @@ -101,7 +101,7 @@ class DownloadTest { assertTrue(fileSystem.exists(tmpDirPath / testFixtures.alphaSha256Hex)) } - @Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals. private fun getApplicationManifestFileName(applicationName: String) = app.cash.zipline.loader.internal.getApplicationManifestFileName(applicationName) diff --git a/zipline-gradle-plugin/src/main/kotlin/app/cash/zipline/gradle/ZiplineCompiler.kt b/zipline-gradle-plugin/src/main/kotlin/app/cash/zipline/gradle/ZiplineCompiler.kt index 2c648d1917..e8196ba97d 100644 --- a/zipline-gradle-plugin/src/main/kotlin/app/cash/zipline/gradle/ZiplineCompiler.kt +++ b/zipline-gradle-plugin/src/main/kotlin/app/cash/zipline/gradle/ZiplineCompiler.kt @@ -162,10 +162,10 @@ internal class ZiplineCompiler( private fun getJsFiles(files: List) = files.filter { it.path.endsWith(".js") } - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. private val manifestFileName = app.cash.zipline.loader.internal.MANIFEST_FILE_NAME - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. private fun collectDependencies(quickJs: QuickJs, bytecode: ByteArray): List { app.cash.zipline.internal.collectModuleDependencies(quickJs) quickJs.execute(bytecode) diff --git a/zipline-gradle-plugin/src/main/kotlin/app/cash/zipline/gradle/ZiplinePlugin.kt b/zipline-gradle-plugin/src/main/kotlin/app/cash/zipline/gradle/ZiplinePlugin.kt index f6b6c47352..7c28f67269 100644 --- a/zipline-gradle-plugin/src/main/kotlin/app/cash/zipline/gradle/ZiplinePlugin.kt +++ b/zipline-gradle-plugin/src/main/kotlin/app/cash/zipline/gradle/ZiplinePlugin.kt @@ -218,7 +218,7 @@ class ZiplinePlugin : KotlinCompilerPluginSupportPlugin { } } - @Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals. private fun generateKeyPair(algorithm: SignatureAlgorithmId) { val logger = LoggerFactory.getLogger(ZiplinePlugin::class.java) val keyPair = app.cash.zipline.loader.internal.generateKeyPair(algorithm) diff --git a/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineCompilerTest.kt b/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineCompilerTest.kt index eb28ee006d..b0c7ac0cb2 100644 --- a/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineCompilerTest.kt +++ b/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineCompilerTest.kt @@ -37,7 +37,7 @@ class ZiplineCompilerTest { private val quickJs = QuickJs.create() @Before - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. fun setUp() { // Configure QuickJS to support module loading. app.cash.zipline.internal.initModuleLoader(quickJs) @@ -224,7 +224,7 @@ class ZiplineCompilerTest { return result } - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. private fun loadJsModule(quickJs: QuickJs, id: String, bytecode: ByteArray) { return app.cash.zipline.internal.loadJsModule(quickJs, id, bytecode) } diff --git a/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineGradleDownloaderTest.kt b/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineGradleDownloaderTest.kt index 142b605797..3c99bcddf7 100644 --- a/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineGradleDownloaderTest.kt +++ b/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineGradleDownloaderTest.kt @@ -100,7 +100,7 @@ class ZiplineGradleDownloaderTest { ) } - @Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals. private fun getApplicationManifestFileName(applicationName: String) = app.cash.zipline.loader.internal.getApplicationManifestFileName(applicationName) } diff --git a/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineGradlePluginTest.kt b/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineGradlePluginTest.kt index 2d393cb0d7..6c7f8c0438 100644 --- a/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineGradlePluginTest.kt +++ b/zipline-gradle-plugin/src/test/kotlin/app/cash/zipline/gradle/ZiplineGradlePluginTest.kt @@ -26,8 +26,14 @@ import java.io.File import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.TaskOutcome import org.junit.Test - -class ZiplineGradlePluginTest { +import org.junit.runner.RunWith +import org.junit.runners.Parameterized +import org.junit.runners.Parameterized.Parameters + +@RunWith(Parameterized::class) +class ZiplineGradlePluginTest( + private val enableK2: Boolean, +) { @Test fun productionBuilds() { val projectDir = File("src/test/projects/basic") @@ -501,13 +507,17 @@ class ZiplineGradlePluginTest { } } - private fun createRunner(projectDir: File, vararg taskNames: String): GradleRunner { + private fun createRunner( + projectDir: File, + vararg taskNames: String, + ): GradleRunner { val gradleRoot = projectDir.resolve("gradle").also { it.mkdir() } File("../gradle/wrapper").copyRecursively(gradleRoot.resolve("wrapper"), true) + val arguments = arrayOf("--info", "--stacktrace", "--continue", "-PenableK2=$enableK2") return GradleRunner.create() .withProjectDir(projectDir) .withDebug(true) // Run in-process. - .withArguments("--info", "--stacktrace", "--continue", *taskNames, versionProperty) + .withArguments(*arguments, *taskNames, versionProperty) .forwardOutput() } @@ -535,7 +545,14 @@ class ZiplineGradlePluginTest { val SUCCESS_OUTCOMES = listOf(TaskOutcome.SUCCESS, TaskOutcome.UP_TO_DATE) val versionProperty = "-PziplineVersion=${System.getProperty("ziplineVersion")}" - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. private val manifestFileName = app.cash.zipline.loader.internal.MANIFEST_FILE_NAME + + @JvmStatic + @Parameters + fun data() = listOf( + arrayOf(true), + arrayOf(false), + ) } } diff --git a/zipline-gradle-plugin/src/test/projects/android/lib/build.gradle.kts b/zipline-gradle-plugin/src/test/projects/android/lib/build.gradle.kts index b614a427e3..f06ec62f1f 100644 --- a/zipline-gradle-plugin/src/test/projects/android/lib/build.gradle.kts +++ b/zipline-gradle-plugin/src/test/projects/android/lib/build.gradle.kts @@ -6,11 +6,22 @@ plugins { kotlin { androidTarget() + js { browser() binaries.executable() } + if (project.property("enableK2").toString().toBooleanStrict()) { + targets.configureEach { + compilations.configureEach { + compilerOptions.options.languageVersion.set( + org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0, + ) + } + } + } + sourceSets { commonMain { dependencies { diff --git a/zipline-gradle-plugin/src/test/projects/basic/lib/build.gradle.kts b/zipline-gradle-plugin/src/test/projects/basic/lib/build.gradle.kts index 7a2ac22eb6..439ee04aed 100644 --- a/zipline-gradle-plugin/src/test/projects/basic/lib/build.gradle.kts +++ b/zipline-gradle-plugin/src/test/projects/basic/lib/build.gradle.kts @@ -15,6 +15,16 @@ kotlin { binaries.executable() } + if (project.property("enableK2").toString().toBooleanStrict()) { + targets.configureEach { + compilations.configureEach { + compilerOptions.options.languageVersion.set( + org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0, + ) + } + } + } + sourceSets { commonMain { dependencies { diff --git a/zipline-gradle-plugin/src/test/projects/crash/lib/build.gradle.kts b/zipline-gradle-plugin/src/test/projects/crash/lib/build.gradle.kts index 2a6fb39be0..cb0f0b1acb 100644 --- a/zipline-gradle-plugin/src/test/projects/crash/lib/build.gradle.kts +++ b/zipline-gradle-plugin/src/test/projects/crash/lib/build.gradle.kts @@ -14,6 +14,16 @@ kotlin { binaries.executable() } + if (project.property("enableK2").toString().toBooleanStrict()) { + targets.configureEach { + compilations.configureEach { + compilerOptions.options.languageVersion.set( + org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0, + ) + } + } + } + sourceSets { commonMain { dependencies { diff --git a/zipline-gradle-plugin/src/test/projects/jvmOnly/lib/build.gradle.kts b/zipline-gradle-plugin/src/test/projects/jvmOnly/lib/build.gradle.kts index 8a2c9def25..4bedf684d5 100644 --- a/zipline-gradle-plugin/src/test/projects/jvmOnly/lib/build.gradle.kts +++ b/zipline-gradle-plugin/src/test/projects/jvmOnly/lib/build.gradle.kts @@ -8,6 +8,16 @@ plugins { kotlin { jvm() + if (project.property("enableK2").toString().toBooleanStrict()) { + targets.configureEach { + compilations.configureEach { + compilerOptions.options.languageVersion.set( + org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0, + ) + } + } + } + sourceSets { val jvmMain by getting { dependencies { diff --git a/zipline-gradle-plugin/src/test/projects/multipleJsTargets/lib/build.gradle.kts b/zipline-gradle-plugin/src/test/projects/multipleJsTargets/lib/build.gradle.kts index de45780b59..38e3667d7f 100644 --- a/zipline-gradle-plugin/src/test/projects/multipleJsTargets/lib/build.gradle.kts +++ b/zipline-gradle-plugin/src/test/projects/multipleJsTargets/lib/build.gradle.kts @@ -24,6 +24,16 @@ kotlin { } } + if (project.property("enableK2").toString().toBooleanStrict()) { + targets.configureEach { + compilations.configureEach { + compilerOptions.options.languageVersion.set( + org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0, + ) + } + } + } + sourceSets { commonMain { dependencies { diff --git a/zipline-gradle-plugin/src/test/projects/signing/lib/build.gradle.kts b/zipline-gradle-plugin/src/test/projects/signing/lib/build.gradle.kts index aac836e4d8..8f609b433a 100644 --- a/zipline-gradle-plugin/src/test/projects/signing/lib/build.gradle.kts +++ b/zipline-gradle-plugin/src/test/projects/signing/lib/build.gradle.kts @@ -13,6 +13,16 @@ kotlin { binaries.executable() } + if (project.property("enableK2").toString().toBooleanStrict()) { + targets.configureEach { + compilations.configureEach { + compilerOptions.options.languageVersion.set( + org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0, + ) + } + } + } + sourceSets { commonMain { dependencies { diff --git a/zipline-kotlin-plugin/src/main/kotlin/app/cash/zipline/kotlin/ZiplineCompilerPluginRegistrar.kt b/zipline-kotlin-plugin/src/main/kotlin/app/cash/zipline/kotlin/ZiplineCompilerPluginRegistrar.kt index 00469d435b..1eaf360a9a 100644 --- a/zipline-kotlin-plugin/src/main/kotlin/app/cash/zipline/kotlin/ZiplineCompilerPluginRegistrar.kt +++ b/zipline-kotlin-plugin/src/main/kotlin/app/cash/zipline/kotlin/ZiplineCompilerPluginRegistrar.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration @OptIn(ExperimentalCompilerApi::class) @AutoService(CompilerPluginRegistrar::class) class ZiplineCompilerPluginRegistrar : CompilerPluginRegistrar() { - override val supportsK2 get() = false + override val supportsK2 get() = true override fun ExtensionStorage.registerExtensions(configuration: CompilerConfiguration) { val messageCollector = configuration.get( diff --git a/zipline-loader/src/commonMain/kotlin/app/cash/zipline/loader/ManifestVerifier.kt b/zipline-loader/src/commonMain/kotlin/app/cash/zipline/loader/ManifestVerifier.kt index 419b841249..58b0ad0e86 100644 --- a/zipline-loader/src/commonMain/kotlin/app/cash/zipline/loader/ManifestVerifier.kt +++ b/zipline-loader/src/commonMain/kotlin/app/cash/zipline/loader/ManifestVerifier.kt @@ -44,7 +44,7 @@ class ManifestVerifier private constructor( * @throws IllegalStateException if no trusted signature is found, or if a signature doesn't * verify. */ - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. fun verify(manifestBytes: ByteString, manifest: ZiplineManifest): String? { if (!doSignatureChecks) return null diff --git a/zipline-loader/src/commonMain/kotlin/app/cash/zipline/loader/ZiplineLoader.kt b/zipline-loader/src/commonMain/kotlin/app/cash/zipline/loader/ZiplineLoader.kt index 776ee98985..6bc025f2bb 100644 --- a/zipline-loader/src/commonMain/kotlin/app/cash/zipline/loader/ZiplineLoader.kt +++ b/zipline-loader/src/commonMain/kotlin/app/cash/zipline/loader/ZiplineLoader.kt @@ -416,7 +416,7 @@ class ZiplineLoader internal constructor( * After identifying a manifest to load this fetches all the code, loads it into a JS runtime, * and runs both the user's initializer and the manifest's specified main function. */ - @Suppress("INVISIBLE_MEMBER") // Access :zipline internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline internals. internal suspend fun loadFromManifest( applicationName: String, eventListener: EventListener, diff --git a/zipline-loader/src/commonTest/kotlin/app/cash/zipline/loader/ProductionFetcherReceiverTest.kt b/zipline-loader/src/commonTest/kotlin/app/cash/zipline/loader/ProductionFetcherReceiverTest.kt index f5f2c5a69d..8575178928 100644 --- a/zipline-loader/src/commonTest/kotlin/app/cash/zipline/loader/ProductionFetcherReceiverTest.kt +++ b/zipline-loader/src/commonTest/kotlin/app/cash/zipline/loader/ProductionFetcherReceiverTest.kt @@ -137,7 +137,7 @@ class ProductionFetcherReceiverTest { assertEquals(testFixtures.alphaByteString, ziplineFileFromCache) } - @Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals. private fun getLog() = app.cash.zipline.internal.getLog(zipline.quickJs) private suspend fun ZiplineLoader.loadOrFail( diff --git a/zipline-loader/src/commonTest/kotlin/app/cash/zipline/loader/ZiplineLoaderTest.kt b/zipline-loader/src/commonTest/kotlin/app/cash/zipline/loader/ZiplineLoaderTest.kt index e06780e637..fb743c7756 100644 --- a/zipline-loader/src/commonTest/kotlin/app/cash/zipline/loader/ZiplineLoaderTest.kt +++ b/zipline-loader/src/commonTest/kotlin/app/cash/zipline/loader/ZiplineLoaderTest.kt @@ -410,7 +410,7 @@ class ZiplineLoaderTest { } } - @Suppress("INVISIBLE_MEMBER") // Access :zipline-loader internals. + @Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") // Access :zipline-loader internals. private fun Zipline.getLog(): String? = app.cash.zipline.internal.getLog(quickJs) private suspend fun ZiplineLoader.loadOrFail( diff --git a/zipline-profiler/src/commonMain/kotlin/app/cash/zipline/profiler/ProfilerClock.kt b/zipline-profiler/src/commonMain/kotlin/app/cash/zipline/profiler/ProfilerClock.kt index 2cf0187f6c..3fd6213f37 100644 --- a/zipline-profiler/src/commonMain/kotlin/app/cash/zipline/profiler/ProfilerClock.kt +++ b/zipline-profiler/src/commonMain/kotlin/app/cash/zipline/profiler/ProfilerClock.kt @@ -19,4 +19,6 @@ internal interface ProfilerClock { val nanoTime: Long } -internal expect object DefaultProfilerClock : ProfilerClock +internal expect object DefaultProfilerClock : ProfilerClock { + override val nanoTime: Long +} diff --git a/zipline-profiler/src/jvmMain/kotlin/app/cash/zipline/profiler/ProfilerClockJvm.kt b/zipline-profiler/src/jvmMain/kotlin/app/cash/zipline/profiler/ProfilerClockJvm.kt index 23e908d9af..4979c81185 100644 --- a/zipline-profiler/src/jvmMain/kotlin/app/cash/zipline/profiler/ProfilerClockJvm.kt +++ b/zipline-profiler/src/jvmMain/kotlin/app/cash/zipline/profiler/ProfilerClockJvm.kt @@ -16,5 +16,5 @@ package app.cash.zipline.profiler internal actual object DefaultProfilerClock : ProfilerClock { - override val nanoTime: Long get() = System.nanoTime() + actual override val nanoTime: Long get() = System.nanoTime() } diff --git a/zipline-profiler/src/nativeMain/kotlin/app/cash/zipline/profiler/ProfilerClockUnix.kt b/zipline-profiler/src/nativeMain/kotlin/app/cash/zipline/profiler/ProfilerClockUnix.kt index 2ba409c91a..0410fa2416 100644 --- a/zipline-profiler/src/nativeMain/kotlin/app/cash/zipline/profiler/ProfilerClockUnix.kt +++ b/zipline-profiler/src/nativeMain/kotlin/app/cash/zipline/profiler/ProfilerClockUnix.kt @@ -16,5 +16,5 @@ package app.cash.zipline.profiler internal actual object DefaultProfilerClock : ProfilerClock { - override val nanoTime: Long get() = kotlin.system.getTimeNanos() + actual override val nanoTime: Long get() = kotlin.system.getTimeNanos() } diff --git a/zipline-testing/build.gradle.kts b/zipline-testing/build.gradle.kts index 0d2619a96c..78ed36f5e1 100644 --- a/zipline-testing/build.gradle.kts +++ b/zipline-testing/build.gradle.kts @@ -1,4 +1,3 @@ -import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile import org.jetbrains.kotlin.gradle.plugin.PLUGIN_CLASSPATH_CONFIGURATION_NAME import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile @@ -69,19 +68,26 @@ kotlin { tasks { // https://kotlinlang.org/docs/whatsnew19.html#library-linkage-in-kotlin-native - withType().all { - kotlinOptions { - freeCompilerArgs += listOf("-Xpartial-linkage-loglevel=ERROR") + withType().configureEach { + compilerOptions { + freeCompilerArgs.addAll("-Xpartial-linkage-loglevel=ERROR") } } // https://youtrack.jetbrains.com/issue/KT-56025 // https://youtrack.jetbrains.com/issue/KT-57203 - named("jsBrowserProductionWebpack").configure { + // Required for K1. + findByName("jsBrowserProductionWebpack")?.apply { dependsOn(named("jsProductionLibraryCompileSync")) dependsOn(named("jsDevelopmentLibraryCompileSync")) } - named("jsBrowserProductionLibraryPrepare").configure { + // Required for K1. + findByName("jsBrowserProductionLibraryPrepare")?.apply { + dependsOn(named("jsProductionExecutableCompileSync")) + dependsOn(named("jsDevelopmentLibraryCompileSync")) + } + // Required for K2. + findByName("jsBrowserProductionLibraryDistribution")?.apply { dependsOn(named("jsProductionExecutableCompileSync")) dependsOn(named("jsDevelopmentLibraryCompileSync")) } diff --git a/zipline-testing/src/jsMain/kotlin/app/cash/zipline/testing/suspendingJs.kt b/zipline-testing/src/jsMain/kotlin/app/cash/zipline/testing/suspendingJs.kt index 293a2636e6..17b432815e 100644 --- a/zipline-testing/src/jsMain/kotlin/app/cash/zipline/testing/suspendingJs.kt +++ b/zipline-testing/src/jsMain/kotlin/app/cash/zipline/testing/suspendingJs.kt @@ -13,10 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@file:OptIn(ExperimentalJsExport::class) + package app.cash.zipline.testing import app.cash.zipline.Zipline import kotlinx.coroutines.CoroutineStart +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex @@ -49,6 +52,7 @@ fun unblockSuspendingJs() { mutex.unlock() } +@OptIn(DelicateCoroutinesApi::class) @JsExport fun callSuspendingEchoService(message: String) { val service = zipline.take("jvmSuspendingEchoService") diff --git a/zipline/build.gradle.kts b/zipline/build.gradle.kts index 892550afac..c91fa1da77 100644 --- a/zipline/build.gradle.kts +++ b/zipline/build.gradle.kts @@ -23,7 +23,7 @@ plugins { val copyTestingJs = tasks.register("copyTestingJs") { dependsOn(":zipline-testing:compileDevelopmentLibraryKotlinJs") - destinationDir = buildDir.resolve("generated/testingJs") + destinationDir = rootProject.layout.buildDirectory.dir("generated/testingJs").get().asFile from(rootDir.resolve("zipline-testing/build/compileSync/js/main/developmentLibrary/kotlin")) } tasks.withType().configureEach { @@ -92,6 +92,14 @@ kotlin { } val androidInstrumentedTest by getting { dependsOn(hostTest) + dependencies { + implementation(libs.assertk) + implementation(libs.junit) + implementation(libs.androidx.test.runner) + implementation(libs.kotlinx.coroutines.test) + implementation(kotlin("test")) + implementation(projects.ziplineTesting) + } } val jvmMain by getting { dependsOn(jniMain) @@ -101,6 +109,7 @@ kotlin { kotlin.srcDir("src/jniTest/kotlin/") resources.srcDir(copyTestingJs) dependencies { + implementation(libs.junit) implementation(projects.ziplineTesting) } } @@ -280,14 +289,6 @@ android { } } -dependencies { - androidTestImplementation(libs.assertk) - androidTestImplementation(libs.junit) - androidTestImplementation(libs.androidx.test.runner) - androidTestImplementation(libs.kotlinx.coroutines.test) - androidTestImplementation(projects.ziplineTesting) -} - fun quickJsVersion(): String { return File(projectDir, "native/quickjs/VERSION").readText().trim() } diff --git a/zipline/src/androidMain/kotlin/app/cash/zipline/QuickJsNativeLoader.kt b/zipline/src/androidMain/kotlin/app/cash/zipline/QuickJsNativeLoader.kt index a88fb2e3f3..d80b794052 100644 --- a/zipline/src/androidMain/kotlin/app/cash/zipline/QuickJsNativeLoader.kt +++ b/zipline/src/androidMain/kotlin/app/cash/zipline/QuickJsNativeLoader.kt @@ -15,6 +15,6 @@ */ package app.cash.zipline -internal fun loadNativeLibrary() { +internal actual fun loadNativeLibrary() { System.loadLibrary("quickjs") } diff --git a/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/ZiplineServiceAdapter.kt b/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/ZiplineServiceAdapter.kt index a49abbb1ce..611129cee9 100644 --- a/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/ZiplineServiceAdapter.kt +++ b/zipline/src/commonMain/kotlin/app/cash/zipline/internal/bridge/ZiplineServiceAdapter.kt @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@file:OptIn(ExperimentalSerializationApi::class) // Zipline must track ContextualSerializer API changes. + package app.cash.zipline.internal.bridge import app.cash.zipline.ZiplineFunction @@ -29,7 +31,6 @@ import kotlinx.serialization.modules.SerializersModule * Adapts [ZiplineService] implementations to receive incoming and send outgoing calls. Most * implementations are generated. */ -@OptIn(ExperimentalSerializationApi::class) // Zipline must track ContextualSerializer API changes. @PublishedApi internal abstract class ZiplineServiceAdapter : KSerializer { private val contextualSerializer = ContextualSerializer(PassByReference::class) @@ -83,7 +84,6 @@ internal fun ziplineServiceAdapter( * key to identify a serializer for [typeName] that has [serializers] for its type arguments. */ @PublishedApi -@OptIn(ExperimentalSerializationApi::class) // Zipline must track ContextualSerializer API changes. internal fun serialName(typeName: String, serializers: List>): String { return buildString { append(typeName) diff --git a/zipline/src/jniMain/kotlin/app/cash/zipline/QuickJs.kt b/zipline/src/jniMain/kotlin/app/cash/zipline/QuickJs.kt index 78b8632480..a79b5e2aef 100644 --- a/zipline/src/jniMain/kotlin/app/cash/zipline/QuickJs.kt +++ b/zipline/src/jniMain/kotlin/app/cash/zipline/QuickJs.kt @@ -174,3 +174,5 @@ actual class QuickJs private constructor( private external fun gc(context: Long) private external fun setMaxStackSize(context: Long, stackSize: Long) } + +internal expect fun loadNativeLibrary() diff --git a/zipline/src/jvmMain/kotlin/app/cash/zipline/QuickJsNativeLoader.kt b/zipline/src/jvmMain/kotlin/app/cash/zipline/QuickJsNativeLoader.kt index b26900f6f9..dbeea79cb1 100644 --- a/zipline/src/jvmMain/kotlin/app/cash/zipline/QuickJsNativeLoader.kt +++ b/zipline/src/jvmMain/kotlin/app/cash/zipline/QuickJsNativeLoader.kt @@ -22,7 +22,7 @@ import java.nio.file.StandardCopyOption.REPLACE_EXISTING import java.util.Locale.US @Suppress("UnsafeDynamicallyLoadedCode") // Only loading from our own JAR contents. -internal fun loadNativeLibrary() { +internal actual fun loadNativeLibrary() { val osName = System.getProperty("os.name").lowercase(US) val osArch = System.getProperty("os.arch").lowercase(US) val nativeLibraryJarPath = if (osName.contains("linux")) {