I want to use the new Vector API from a Kotlin project using a Gradle build.
I tried this:
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
kotlinOptions.freeCompilerArgs = listOf("--add-modules", "jdk.incubator.vector")
}
Result is:
Invalid argument: --add-modules
I've checked and the right SDK is being used, and help for javac at least shows --add-modules as a valid flag, so what I guess is going on is, this is the Kotlin compiler, and I need to provide a different flag, or some kind of prefixed flag to add a module to the classpath. What is the magic incantation here?
The Kotlin compiler's argument for this is named -Xadd-modules. You can pass it in this way:
kotlinOptions.freeCompilerArgs = listOf("-Xadd-modules=jdk.incubator.vector")
(Note that right now there is a bug KT-54288 which incorrectly makes this compiler argument unnecessary. So until it's fixed, you can get away without adding it to the build.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With