is it possible to use the newest version of the co...
# compiler
p
is it possible to use the newest version of the compiler, but produce Kotlin metadata understandable by a significantly older version? E.g. use 2.1.0 but make it consumable by 1.8.0. I'm looking at https://kotlinlang.org/docs/compiler-reference.html but neither
-language-version version
or
-api-version version
seems to be the right parameter. More context is in this issue: Kotlin version mismatch possible when using bindings from server . TL;DR: there's a server that vends JARs with compiled Kotlin, and the consumers of these JARs may be arbitrarily old. The compiler does fail with a clear error message, but I'm wondering if it's possible to make it work despite the version discrepancy. Obviously we could downgrade the compiler, but I'd like to know if it's possible to use the latest version to benefit from various improvements, similarly to the Java compiler being able to produce .class files understandable by older Javas (
-Xjdk-release
)
d
Kotlin supports forward compatibility up to 1 version. So if you need to produce binaries compatible with 1.8.x you need to use language version 1.9 or less. In the other hand, compiler supports previous 3 versions, so you can set lv 1.9 with 2.0.x, 2.1.x, 2.2.x but not with 2.3.x API version determines which API from the standard library you can use, so to be fully compatible with 1.8.x binaries you need to set LV to 1.9 and AV to 1.8
1
👍 2
p
great article, thanks! exactly what I need
🙌 1