*Is it possible to set `KotlinCompile.kotlinOption...
# gradle
j
Is it possible to set
KotlinCompile.kotlinOptions.freeCompilerArgs
via CLI, when executing a gradle task?
Context : I have my Android project’s root gradle file configured as bellow, this is to be able to generate Jetpack Compose compiler metrics.
Copy code
subprojects {
    tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
        kotlinOptions {
            if (project.findProperty("enableComposeReports") == "true") {
                freeCompilerArgs += ["-P", "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + rootProject.buildDir.absolutePath + "/compose_metrics/"]
            }
        }
    }
}
So, instead of setting this up in
gradle
, can I pass these
freeCompilerArgs
via CLI when executing a gradle task itself? Something like this (this is just an example):
Copy code
./gradlew assembleRelease -Pkotlin.compiler.arguments="plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=<path>"
v
Only if you code such a forward from command line to the task. There is no generic "set property X of task Y" command line option.
j
Thank you for the reply Björn Kautler
On the off chance of somebody else looking for the same thing, here is a working solution https://stackoverflow.com/a/76081691/10323788