I'm trying to use the @Serializable
annotation in Kotlin. I can build the project with Gradle, but it's showing up red in IntelliJ and when I hover on the @Serializable
annotation, there's a message saying:
kotlinx.serializable compiler plugin is not applied to the module, so this
annotation would not be processed. Make sure you've setup your buildscript
correctly and re-import project.
My build.gradle.kts
file looks like this:
plugins {
id("org.jetbrains.kotlin.jvm").version("1.3.50")
id("org.jetbrains.kotlin.plugin.serialization") version "1.3.50"
idea
}
repositories {
jcenter()
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation(group = "com.charleskorn.kaml", name = "kaml", version = "0.12.0")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}
I have the most recent version of the Kotlin plugin (1.3.50) installed.
DataClassWithSerializableAnnotation.serializer()
./gradlew idea
and then open the generated project.build.gradle.kts
file rather than run./gradlew idea
. Thanks for your help!