wojta / sqldelight-node-sqlite3-driver

Driver for library SQLDelight that supports sqlite3 Node.js module
Apache License 2.0
3 stars 1 forks source link

Task with name 'kotlinNpmInstall' not found in project ':shared'. #10

Open alaa-alshaikh opened 1 month ago

alaa-alshaikh commented 1 month ago

I have a Kotlin Multiplatform project targeting iOS, Android, and Node.js. After upgrading to SQLDelight 2.0.2, I am using the cz.sazel.sqldelight:node-sqlite3-driver-js:0.3.2 for the Node.js target.

I attempted to add the following task to install SQLite3 bindings:

val bindingsInstall = tasks.register("sqlite3BindingsInstall") {
    doLast {
        val sqlite3moduleDir = buildDir.resolve("js/node_modules/sqlite3")
        if (!sqlite3moduleDir.resolve("lib/binding").exists()) {
            exec {
                workingDir = sqlite3moduleDir
                val yarnPath = "${yarn.yarnSetupTaskProvider.get().destination.absolutePath}/bin"
                val nodePath = "${kotlinNodeJsExtension.nodeJsSetupTaskProvider.get().destination.absolutePath}/bin"
                environment(
                    "PATH",
                    System.getenv("PATH") + ":$yarnPath:$nodePath"
                )
                commandLine("$yarnPath/yarn")
            }
        }
    }
}.get()
tasks.named("kotlinNpmInstall") {
    finalizedBy(bindingsInstall)
}

However, I am encountering the following error:

Task with name 'kotlinNpmInstall' not found in project ':shared'.

Project Structure project │ ├── shared │ ├── build.gradle.kts │ └── src │ ├── commonMain │ ├── jsMain │ ├── androidMain │ └── iosMain ├── build.gradle.kts ├── settings.gradle.kts └── other-modules

wojta commented 1 month ago

Hi. Are you sure that kotlin JS is initialized in shared/build.gradle.kts like this (see below)?

https://github.com/wojta/example-sqldelight-node-sqlite3-driver/blob/master/build.gradle.kts#L25-L30

Update and sync Gradle if it's not there.