Hello! I’m having trouble getting `compilerArgs` i...
# ksp
g
Hello! I’m having trouble getting
compilerArgs
in
SymbolProcessorEnvironment
, it’s always empty 🤦‍♂️ More in 🧵
In my gradle plugin:
Copy code
private fun Project.configureCompileArgs() {
    val kotlin = extensions.getByType(KotlinMultiplatformExtension::class.java)
    kotlin.targets.configureEach { target ->
        if (target.fromIosFamily()) {
            tasks.withType(KspTaskNative::class.java).configureEach { compileTask ->
                compileTask.compilerOptions {
                        freeCompilerArgs.addAll(
                            "-P",
                            "plugin:com.google.devtools.ksp:myCustomParameter=Something"
                        )
                    println(">>>>>> ${freeCompilerArgs.get()}")
                }
            }
        }
    }
}
running build:
Copy code
> Configure project :shared
> MyPlugin:
	
>>>>>> [-P, plugin:com.google.devtools.ksp.myCustomParameter=Something, ....
but when the task (for instance kspKotlinIosArm64 ) runs, there are no params:
Copy code
> Task :shared:kspKotlinIosArm64 
>>>>>>>>>>>>> {}
Copy code
public class ProcessorProvider : SymbolProcessorProvider {
    override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
        println(">>>>>>>>>>>>>>>>>  ${environment.options}")
        return Processor(environment.codeGenerator, environment.logger, environment.options)
    }
}
I have no ideas 😞
found it!
Copy code
val ksp = extensions.getByType(KspExtension::class.java)
ksp.apply {
    arg("someVar", "blah")
}
println(">>>>>> ${ksp.arguments}")
worked 😎
t
Tip on Gradle syntax:
project.configure<KspExtension> { arg(...) }
👌 1