https://kotlinlang.org logo
#compose
Title
# compose
m

Mehdi Haghgoo

12/21/2020, 6:34 AM
Hi. Why do we use the following in build.gradle?
Copy code
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
    kotlinOptions {
        jvmTarget = "1.8"
        freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
    }
g

gildor

12/21/2020, 6:40 AM
Because compose uses new IR backend, so it required additional flag to use as dependency skip-prerelease-check required because compoise can be build using pre-release version of Kotlin compiler and by default it not allowed to depend on such dependencies
m

Mehdi Haghgoo

12/21/2020, 6:52 AM
My project works ok without these lines. So, they're optional?
g

gildor

12/21/2020, 8:12 AM
They are not optional in general, maybe applied automatically now by Compose plugin? not sure
j

jim

12/21/2020, 4:53 PM
I don't remember exactly when/where they come into play, I think they were built up over the last year as people complained about issues in their config. IIRC, the
1.8
target is probably because Android or R8 might choke if you use some JVM features from a higher language? Maybe the first flag
-Xallow-jvm-ir-dependencies
is for when you have a project with multiple modules where a non-compose module depends upon a compose module; I think this first flag may become obsolete in
1.4.30
but I'm not sure if that has been 100% decided that it is now safe to remove the binary source check. The second flag (
-Xskip-prerelease-check
) might already be obsolete since we are now on stable Kotlins; I think Compose was being built with pre-release versions of Kotlin at the time we started recommending that flag. Basically, none of them would hurt you, and they might help you. Feel free to remove them at your own risk, but please don't complain build errors or IDE diagnostics you may encounter after having removed them.
🙏 1