kotlingradlegradle-kotlin-dslcompose-desktop

The 'ksp' configuration is deprecated in Kotlin Multiplatform projects. Please use target-specific configurations like 'kspJvm' instead


when I want to run Compose Desktop project i get this warning

The 'ksp' configuration is deprecated in Kotlin Multiplatform projects. Please use 
target-specific configurations like 'kspJvm' instead.
Invalid Java installation found at '/usr/lib/jvm/openjdk-11' (Common Linux Locations). 
It will be re-checked in the next build. This might have performance impact if it keeps 
failing. Run the 'javaToolchains' task for more details.

how can I use taget-specific configurations like KspJvm ?


Solution

  • To set up KSP, you have to add your processor as a dependency to the project like this:

    dependencies {
        ksp(project(":test-processor"))
    }
    

    When you do that, you are, in Gradle terminology, adding your processor library to the ksp configuration.

    The warning tells you to use the specific ones instead for Kotlin multiplatform, which will have been added to your project based on the multiplatform source sets available.

    For example, if you are targeting the JVM with your project and your KSP processing, you can do:

    dependencies {
        kspJvm(project(":test-processor"))
    }
    

    Or for common code (where the slightly unusual metadata name comes from the name Kotlin have given to the common target):

    dependencies {
        kspCommonMainMetadata(project(":test-processor")) 
    }
    

    If you want to be sure what configurations are available, add

    configurations.forEach { println(it.name) }
    

    temporarily to your build file, then run Gradle (./gradlew) and it will print their names to the console.