My apologies for a noob question: I'm trying to check out how serialization works in Kotlin.
To this end, I created a Gradle project like this:
edited the generated build.gradle.kts
by adding just one line
plugins {
java
kotlin("jvm") version "1.3.71"
id("org.jetbrains.kotlin.plugin.serialization") version "1.3.71"
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
testCompile("junit", "junit", "4.12")
}
configure<JavaPluginConvention> {
sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}
and created this Kotlin source file:
import kotlinx.serialization.*
import kotlinx.serialization.json.*
@Serializable
data class Data(val a: Int, val b: String = "42")
But when I build this project, I get this error:
Unresolved reference: kotlinx
If I remove the first two offending lines, I get this error instead:
Cannot access 'Serializable': it is internal in 'kotlin.io'
What am I doing wrong here? (Also, do I need Gradle to use serialization in IntelliJ/Kotlin 1.3.71? )