Hello, where should I put the `-Xexpect-actual-cla...
# multiplatform
d
Hello, where should I put the
-Xexpect-actual-classes
to supress the warnings? My
gradle.properties
contains
org.gradle.jvmargs=-Xmx8192M -Dfile.encoding=UTF-8 -Dkotlin.daemon.jvm.options\="-Xmx8192M"
, but idk whether i should put it just there or into
-Dkotlin...options
. Doing both seems to be causing some gradle issues.
m
Something like this should do it:
Copy code
tasks.withType(KotlinCompile::class.java).configureEach { 
  kotlinOptions {
    freeCompilerArgs = freeCompilerArgs +"-Xexpect-actual-classes"
  }
}
Or alternatively:
Copy code
kotlin {
  targets.all {
    compilations.all {
      compilerOptions.options.freeCompilerArgs.add("-Xexpect-actual-classes")
    }
  }
}
Both are Gradle Kotlin DSL. I don't think you can set Kotlin compiler options from
gradle.properties
only
d
Ok, thank you, I could not find much info on it online. I'll go for this one, its much more inline with the rest of my file. They are both equivalent by meaning, its just different syntax, right?
```kotlin {
targets.all {
compilations.all {
compilerOptions.options.freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
}```
m
I'm a bit lost TBH, it might depend if you're using multiplatform or not and your Kotlin version. The DSL changed a bit recently
d
Well, I am totally lost in this gradle stuff, but the problem is that cleanbuild is taking about 45min so I don't have much space for experimentation
m
This is how we do it in our repo if you're curious
j
This is how I'm doing it. I found the
KotlinCompile
task method didn't work for the IDE to stop showing warnings. But that might have been fixed now in 1.9.22.
r
Since kotlin 1.9.20 or so you can suppress the warnings this way:
Copy code
sourceSets {
all { 
languageSettings.enableLanguageFeature("ExpectActualClasses") 
}
val commonMain by getting { ... }
....
}
👀 1
d
I am on 1.9.20 and it does not work for me sadly, so maybe from 1.9.21