Hello everyone! I wouldn't like to look rude, but ...
# webassembly
p
Hello everyone! I wouldn't like to look rude, but could you tell me, how can I remove wasm target in my Kotlin Multiplatfrom sample project? The reason I would like to is that it is actually alpha and causes dependency problems, sorry to say that. Or maybe I just can't fix dependencies the right way yet.
Or maybe somebody knows some other solution in my situation. So here's the build.gradle.ts:
Copy code
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.jetbrainsCompose)
    alias(libs.plugins.compose.compiler)
    // see: <https://kotlinlang.org/docs/ksp-quickstart.html>
    id("com.google.devtools.ksp") version "2.0.20-1.0.24"
}

/*
// see: <https://github.com/google/ksp/blob/9faf2165dc393363f98948442333b88751676ffa/examples/multiplatform/build.gradle.kts#L5>
allprojects {
    repositories {
        mavenCentral()
    }
}

 */

kotlin {
    @OptIn(ExperimentalWasmDsl::class)
    wasmJs {
        moduleName = "composeApp"
        browser {
            val projectDirPath = project.projectDir.path
            commonWebpackConfig {
                outputFileName = "composeApp.js"
                devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
                    static = (static ?: mutableListOf()).apply {
                        // Serve sources to debug inside browser
                        add(projectDirPath)
                    }
                }
            }
        }
        binaries.executable()
    }

    jvm("desktop")

    sourceSets {
        val desktopMain by getting
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.material3)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            implementation(libs.androidx.lifecycle.viewmodel)
            implementation(libs.androidx.lifecycle.runtime.compose)
            implementation("org.jetbrains.androidx.navigation:navigation-compose:2.7.0-alpha07")
//            implementation(libs.compose.navigation)
            implementation(project.dependencies.platform(libs.koin.bom))
            implementation(libs.koin.core)
            implementation("com.google.dagger:dagger-compiler:2.51.1")
//            ksp("com.google.dagger:dagger-compiler:2.51.1")
        }
        desktopMain.dependencies {
            implementation(compose.desktop.currentOs)
            implementation(libs.kotlinx.coroutines.swing)
        }
    }
}


compose.desktop {
    application {
        mainClass = "org.example.project.MainKt"

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "org.example.project"
            packageVersion = "1.0.0"
        }
    }
}
And here's the error I get:
Copy code
Could not determine the dependencies of task ':kotlinNpmInstall'.
> Could not resolve all dependencies for configuration ':composeApp:wasmJsNpmAggregated'.
   > Could not resolve com.google.devtools.ksp:symbol-processing-api:1.9.20-1.0.14.
     Required by:
         project :composeApp > com.google.dagger:dagger-compiler:2.51.1
         project :composeApp > com.google.dagger:dagger-compiler:2.51.1 > com.google.dagger:dagger-spi:2.51.1
      > No matching variant of com.google.devtools.ksp:symbol-processing-api:1.9.20-1.0.14 was found. The consumer was configured to find a library for use during 'kotlin-runtime', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.js.public.package.json' with value 'public-package-json', attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm', attribute 'org.jetbrains.kotlin.wasm.target' with value 'js' but:
          - Variant 'apiElements' declares a library, preferably optimized for standard JVMs:
              - Incompatible because this component declares a component for use during compile-time, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.js.public.package.json (required 'public-package-json')
                  - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js')
          - Variant 'runtimeElements' declares a library for use during runtime, preferably optimized for standard JVMs:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.js.public.package.json (required 'public-package-json')
                  - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js')
   > Could not resolve com.squareup:kotlinpoet:1.11.0.
     Required by:
         project :composeApp > com.google.dagger:dagger-compiler:2.51.1
      > No matching variant of com.squareup:kotlinpoet:1.11.0 was found. The consumer was configured to find a library for use during 'kotlin-runtime', preferably optimized for non-jvm, as well as attribute 'org.jetbrains.kotlin.js.public.package.json' with value 'public-package-json', attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm', attribute 'org.jetbrains.kotlin.wasm.target' with value 'js' but:
          - Variant 'apiElements' declares a library, preferably optimized for standard JVMs:
              - Incompatible because this component declares a component for use during compile-time, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component for use during 'kotlin-runtime', as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.js.public.package.json (required 'public-package-json')
                  - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js')
          - Variant 'runtimeElements' declares a library for use during runtime, preferably optimized for standard JVMs:
              - Incompatible because this component declares a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' and the consumer needed a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'wasm'
              - Other compatible attributes:
                  - Doesn't say anything about org.jetbrains.kotlin.js.public.package.json (required 'public-package-json')
                  - Doesn't say anything about org.jetbrains.kotlin.wasm.target (required 'js')

* Try:
> Review the variant matching algorithm at <https://docs.gradle.org/8.7/userguide/variant_attributes.html#sec:abm_algorithm>.
> No matching variant errors are explained in more detail at <https://docs.gradle.org/8.7/userguide/variant_model.html#sub:variant-no-match>.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to <https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.
BUILD FAILED in 1s
BTW, desktopJar is fine:
Copy code
5:10:07 PM: Executing 'desktopJar'...

Starting Gradle Daemon...
Gradle Daemon started in 4 s 484 ms
Type-safe project accessors is an incubating feature.
> Task :composeApp:checkKotlinGradlePluginConfigurationErrors SKIPPED
> Task :composeApp:convertXmlValueResourcesForCommonMain UP-TO-DATE
> Task :composeApp:copyNonXmlValueResourcesForCommonMain UP-TO-DATE
> Task :composeApp:prepareComposeResourcesTaskForCommonMain UP-TO-DATE
> Task :composeApp:generateResourceAccessorsForCommonMain UP-TO-DATE
> Task :composeApp:convertXmlValueResourcesForDesktopMain NO-SOURCE
> Task :composeApp:copyNonXmlValueResourcesForDesktopMain NO-SOURCE
> Task :composeApp:prepareComposeResourcesTaskForDesktopMain NO-SOURCE
> Task :composeApp:generateResourceAccessorsForDesktopMain NO-SOURCE
> Task :composeApp:generateActualResourceCollectorsForDesktopMain UP-TO-DATE
> Task :composeApp:generateComposeResClass UP-TO-DATE
> Task :composeApp:generateExpectResourceCollectorsForCommonMain UP-TO-DATE
> Task :composeApp:assembleDesktopMainResources UP-TO-DATE
> Task :composeApp:desktopProcessResources UP-TO-DATE
> Task :composeApp:compileKotlinDesktop
> Task :composeApp:desktopMainClasses
> Task :composeApp:desktopJar UP-TO-DATE

Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

For more on this, please refer to <https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings> in the Gradle documentation.

BUILD SUCCESSFUL in 34s
11 actionable tasks: 1 executed, 10 up-to-date
5:10:42 PM: Execution finished 'desktopJar'.
Even after a few tries of fixing keep getting errors. New build:
Copy code
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.jetbrainsCompose)
    alias(libs.plugins.compose.compiler)
    // see: <https://kotlinlang.org/docs/ksp-quickstart.html>
    id("com.google.devtools.ksp") version "2.0.20-1.0.24"
}

/*
// see: <https://github.com/google/ksp/blob/9faf2165dc393363f98948442333b88751676ffa/examples/multiplatform/build.gradle.kts#L5>
allprojects {
    repositories {
        mavenCentral()
    }
}
*/
// see: <https://kotlinlang.org/docs/ksp-quickstart.html#add-a-processor>
repositories {
    mavenCentral()
}


kotlin {
    @OptIn(ExperimentalWasmDsl::class)
    wasmJs {
        moduleName = "composeApp"
        browser {
            val projectDirPath = project.projectDir.path
            commonWebpackConfig {
                outputFileName = "composeApp.js"
                devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
                    static = (static ?: mutableListOf()).apply {
                        // Serve sources to debug inside browser
                        add(projectDirPath)
                    }
                }
            }
        }
        binaries.executable()
    }

    jvm("desktop")

    sourceSets {
        val desktopMain by getting
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.material3)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            implementation(libs.androidx.lifecycle.viewmodel)
            implementation(libs.androidx.lifecycle.runtime.compose)
            implementation("org.jetbrains.androidx.navigation:navigation-compose:2.7.0-alpha07")
//            implementation(libs.compose.navigation)
            implementation(project.dependencies.platform(libs.koin.bom))
            implementation(libs.koin.core)
            implementation("com.google.dagger:dagger-compiler:2.51.1")
//            ksp("com.google.dagger:dagger-compiler:2.51.1")
            implementation(kotlin("stdlib-jdk8"))
            implementation("com.google.dagger:dagger-compiler:2.51.1")
//            ksp("com.google.dagger:dagger-compiler:2.51.1")

        }
        desktopMain.dependencies {
            implementation(compose.desktop.currentOs)
            implementation(libs.kotlinx.coroutines.swing)
        }
    }
}


compose.desktop {
    application {
        mainClass = "org.example.project.MainKt"

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "org.example.project"
            packageVersion = "1.0.0"
        }
    }
}
Well, new error:
Copy code
:composeApp:desktopMain: Could not find androidx.lifecycle:lifecycle-viewmodel:2.8.0.
Searched in the following locations:
  - <https://repo.maven.apache.org/maven2/androidx/lifecycle/lifecycle-viewmodel/2.8.0/lifecycle-viewmodel-2.8.0.pom>
Required by:
    project :composeApp > org.jetbrains.androidx.lifecycle:lifecycle-viewmodel:2.8.0

Possible solution:
 - Declare repository providing the artifact, see the documentation at <https://docs.gradle.org/current/userguide/declaring_repositories.html>
I know I'm a kinda newbie, I hope you will forgive =)
One more try:
Copy code
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
    alias(libs.plugins.kotlinMultiplatform)
    alias(libs.plugins.jetbrainsCompose)
    alias(libs.plugins.compose.compiler)
    // see: <https://kotlinlang.org/docs/ksp-quickstart.html>
    id("com.google.devtools.ksp") version "2.0.20-1.0.24"
}

/*
// see: <https://github.com/google/ksp/blob/9faf2165dc393363f98948442333b88751676ffa/examples/multiplatform/build.gradle.kts#L5>
allprojects {
    repositories {
        mavenCentral()
    }
}
// see: <https://kotlinlang.org/docs/ksp-quickstart.html#add-a-processor>
repositories {
    mavenCentral()
}
*/


kotlin {
    @OptIn(ExperimentalWasmDsl::class)
    wasmJs {
        moduleName = "composeApp"
        browser {
            val projectDirPath = project.projectDir.path
            commonWebpackConfig {
                outputFileName = "composeApp.js"
                devServer = (devServer ?: KotlinWebpackConfig.DevServer()).apply {
                    static = (static ?: mutableListOf()).apply {
                        // Serve sources to debug inside browser
                        add(projectDirPath)
                    }
                }
            }
        }
        binaries.executable()
    }

    // see: <https://kotlinlang.org/docs/ksp-multiplatform.html>
    jvm{
        withJava()
    }
    linuxX64() {
        binaries {
            executable()
        }
    }

    sourceSets {
        val commonMain by getting
        val linuxX64Main by getting
        val linuxX64Test by getting
        val desktopMain by getting
        commonMain.dependencies {
            implementation(compose.runtime)
            implementation(compose.foundation)
            implementation(compose.material)
            implementation(compose.material3)
            implementation(compose.ui)
            implementation(compose.components.resources)
            implementation(compose.components.uiToolingPreview)
            implementation(libs.androidx.lifecycle.viewmodel)
            implementation(libs.androidx.lifecycle.runtime.compose)
            implementation("org.jetbrains.androidx.navigation:navigation-compose:2.7.0-alpha07")
//            implementation(libs.compose.navigation)
            implementation(project.dependencies.platform(libs.koin.bom))
            implementation(libs.koin.core)
            implementation("com.google.dagger:dagger-compiler:2.51.1")
//            ksp("com.google.dagger:dagger-compiler:2.51.1")
            implementation(kotlin("stdlib-jdk8"))
            implementation("com.google.dagger:dagger-compiler:2.51.1")
//            ksp("com.google.dagger:dagger-compiler:2.51.1")

        }
        desktopMain.dependencies {
            implementation(compose.desktop.currentOs)
            implementation(libs.kotlinx.coroutines.swing)
        }
    }
}


compose.desktop {
    application {
        mainClass = "org.example.project.MainKt"

        nativeDistributions {
            targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
            packageName = "org.example.project"
            packageVersion = "1.0.0"
        }
    }
}
dependencies{

add("kspCommonMainMetadata", project(":test-processor"))
add("kspJvm", project(":test-processor"))
add("kspJvmTest", project(":test-processor")) // Not doing anything because there's no test source set for JVM
// There is no processing for the Linux x64 main source set, because kspLinuxX64 isn't specified
add("kspLinuxX64Test", project(":test-processor"))
}
The error:
c
At the start of the
kotlin {}
block, each platform is registered. If you comment out the related sub-block, it disables the platform.
2
I don't use #C013BA8EQSE so I couldn't tell you what the problem is. Maybe it just doesn't support WASM yet. If you want to solve the issue, you could ask them.
p
Thanks, I'll try.
Yeah, now both the gradle sync and project build and run done. Maybe not a solution but a perfect temporary workaround. Thanks!