Phani Mahesh
08/20/2020, 3:28 PMZach Klippenstein (he/him) [MOD]
08/20/2020, 3:44 PMandylamax
08/20/2020, 3:45 PMPhani Mahesh
08/20/2020, 3:46 PMudalov
-api-version 1.3. This will allow you to use new language features, but not the new API. It’s called apiVersion in Gradle, I thinkPhani Mahesh
08/20/2020, 3:54 PMPhani Mahesh
08/20/2020, 3:55 PMudalov
Zach Klippenstein (he/him) [MOD]
08/20/2020, 4:51 PMapiVersion doesn’t actually change the version of the stdlib that is depended on. Should it? I think this is a requirement for libraries that want to use 1.4 but not automatically drag the 1.4 stdilb into their consumers’ transitive deps, otherwise they need to explicitly configure dependency resolution – right?udalov
-api-version is not enough, you also need to tell the build to avoid adding dependency on the default kotlin-stdlib, and depend manually on 1.3 instead. And in this case, I suppose -api-version is not even useful anymore.
So instead of my initial advice, one should use Kotlin compiler 1.4, but with an explicit dependency on kotlin-stdlib 1.3. No need for -api-version. Then it will work as intended: 1.4 language features are enabled, 1.4 stdlib APIs are not.
(Note that telling the Kotlin compiler 1.3 to use language 1.4 is generally not OK for libraries because it moves the compiler into the “pre-release” mode so that produced binaries will not be readable by the released 1.4+ compilers.)Phani Mahesh
08/20/2020, 5:27 PMZach Klippenstein (he/him) [MOD]
08/20/2020, 6:39 PMapiVersion to avoid warnings. It’s a lot more work than just not upgrading to 1.4 at all.