Hello,
I recently became interested in Scala because the PEG parser library Parboiled runs significantly faster in Scala than in Kotlin.
I’m currently developing a plugin for JetBrains IDEs using Kotlin and Gradle. I’d like to include some Scala code alongside my main Kotlin code. Here is my build.gradle.kts:
plugins {
kotlin("jvm") version "2.1.20"
scala
}
group = "io.parstools"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("org.parboiled:parboiled_2.13:2.1.8")
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<ScalaCompile> {
scalaCompileOptions.apply {
additionalParameters = listOf("-deprecation", "-feature", "-unchecked")
}
}
kotlin {
jvmToolchain(17)
}
Even though I’m not explicitly setting any -target:jvm-XX flag, I get the following error when compiling a simple Scala function (not even using Parboiled yet):
Task :compileScala FAILED
2 actionable tasks: 2 executed
'jvm-1.17' is not a valid choice for '-target'
bad option: '-target:jvm-1.17'
What might be causing this error? How can I ensure Kotlin and Scala sources can coexist and compile cleanly in one Gradle project?
Any guidance or best practices for setting up a mixed Kotlin + Scala Gradle project would be appreciated.