Closed GavinRay97 closed 6 months ago
Can you post a minimal example to reproduce this, ideally with the code for logging javac arguments. Also, try javacArguments.addAll("--enable-preview", "-source", "16")
since --enable-preview
has to be used together with -source
or --release
, apparently.
Sure -- thanks for getting back to me.
I've attached a minimal project in a .zip
below -- you can get the repro and the debug output containing the kapt
params with javac args by running:
./gradlew test --info
Which should print output like:
kotline-compile-test-repro.zip
I think the issue is here, fwiw: https://github.com/tschuchortdev/kotlin-compile-testing/blob/82ec5425c52e968ae706af0f667d8fe2fe5efdca/core/src/main/kotlin/com/tschuchort/compiletesting/KotlinCompilation.kt#L360-L374
The javac
arguments don't seem to be passed through here.
public final class KaptOptions : org.jetbrains.kotlin.base.kapt3.KaptFlags {
// ...
public final class Builder public constructor() {
// ...
public final val javacOptions: kotlin.collections.MutableMap<kotlin.String, kotlin.String> /* compiled code */
I tried to fork and modify your code, but since javacOptions
here expects a Map
, I couldn't figure out how to pass arguments that don't expect an -foo=X
value like --enable-preview
.
I found a small handful of repos which seem to have --enable-preview
being passed to kapt
via javacOptions
:
kapt {
javacOptions {
option("--enable-preview", "")
}
}
kapt {
arguments {
arg("mapstruct.unmappedTargetPolicy", "IGNORE")
}
javacOptions {
option("--enable-preview")
}
}
I'm trying to write an annotation processor which imports
java.lang.foreign.MemorySegment
from the Panama API's.My config is:
When running this though, I get:
Is there any way to enable preview API's/does someone have an example of doing this? Thank you! 🙏
It looks like
javacOptions
is not receiving the--enable-preview
flag inkapt
, I think: