Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin Gradle plugin: apiVersion vs languageVersion

Tags:

gradle

kotlin

Kotlin Gradle plugin contains compileKotlin task which can be configured by apiVersion and languageVersion parameters (doc):

compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ['-Xjsr305=strict']
        jvmTarget = '1.8'
        languageVersion = '1.1'
        apiVersion = '1.1'
    }
}

Both parameters are used for compatibility with older Kotlin versions. Could somebody explain what is the difference between them? And what are use cases using each of them?

like image 339
Max Farsikov Avatar asked Mar 15 '26 21:03

Max Farsikov


1 Answers

apiVersion: Allow to use declarations only from the specified version of bundled libraries

languageVersion: Provide source compatibility with specified language version

You can see full documentation here: https://kotlinlang.org/docs/reference/using-gradle.html

and this reference: https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html

like image 78
Andri Sul Avatar answered Mar 18 '26 16:03

Andri Sul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!