How do I set a Kotlin compiler switch in a multipl...
# multiplatform
e
How do I set a Kotlin compiler switch in a multiplatform
build.gradle.kts
?
r
Copy code
sourceSets {
    all {
        languageSettings.optIn("kotlin.time.ExperimentalTime")
        languageSettings.optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
        languageSettings.optIn("kotlinx.serialization.ExperimentalSerializationApi")
    }
this is for an optin if thats what you want
e
@Robert Munro thanks! This one is also useful. Although I was thinking about switches like
-Xdebug
r
Ok that's a JVM switch
Or are you looking to do native debugging?
Or gradle debug info?
e
I was looking at https://kotlinlang.org/docs/debug-flow-with-idea.html#optimized-out-variables And it mention it as "compiler argument", that's why I've used that name
r
Are you running your code on JVM? I usually get to the issue quicker by just logging out info sometimes. Sometimes breakpoints are missed or unpredictable as coroutines are concurrent
e
I am running the
commonTest
tests on the JVM as of now, yes. I'd like to test out
-Xdebug
as any enhancement on DevEx is a +1 when I'll get to present a multiplatform POC
Keep in mind a team coming from Java will use the debugger extensively (me included), so any other approach may break the workflow.
r
So what is going wrong? Maybe post the error or failure you are getting in the test?
seems like -Xdebug might be a red herring - but not sure of the use case
if you are using intellij and the tests are quite liner codewise then it should be handled automatically by IJ
e
See that I can't access anymore
socket
,
connect
and
serviceLevel
at that point. Which makes the debug experience miserable
r
ok so yes i see the optimised out message
you can make an andriod section in your kvm module
Copy code
android {
    javaCompileOptions {
       compileOptions {
          arguments += ["-Xebug":true]
       }
    }
   
}
it just a guess though ..
assumoing u are using kts build
e
Copy code
val configuration: KotlinCompilationTask<*>.() -> Unit = {
  val isDebug = project.property("your.debug.prop")

  if (isDebug == "true") {
    compilerOptions {
      freeCompilerArgs.add("-Xdebug")
    }
  }
}

tasks.named<KotlinCompilationTask<*>>("compileKotlinJvm", configuration)
tasks.named<KotlinCompilationTask<*>>("compileTestKotlinJvm", configuration)
This does the trick it seems.