Hi, I was setting up a project with Gradle Convent...
# ksp
m
Hi, I was setting up a project with Gradle Convention Plugins, where in I need to setup ksp plugin for komapper. Komapper can be configured by specifying options in gradle script, I'm stuck here on how to set this up in Convention Plugins.
Copy code
ksp {
  arg("komapper.enumStrategy", "ordinal")
  arg("komapper.namingStrategy", "UPPER_SNAKE_CASE")
}
Any help would be really helpful. Thanks!
g
Copy code
class MyPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        target.apply(plugin = "com.google.devtools.ksp")
        target.extensions.configure(KspExtension::class.java) {
            arg("komapper.enumStrategy", "ordinal")
            arg("komapper.namingStrategy", "UPPER_SNAKE_CASE")
        }
    }
}
Something like that
(To get access to KspExtension you need your build gradle file of your convention plugin module to define the dependency to ksp plugin.)
m
Thanks, this really helped. ❤️
y
You might need to run the configuration block in an afterEvaluate unfortunately
y
the reason doing this without
afterEvaluate
doesn’t work for me is the value of my args come from a custom plugin extension which uses lazy providers like
val myValue: Property<Boolean>
Because `KspExtension`’s
arg
require the lazy properties to be evaluated eagerly but the values aren’t be available during configuration, the
arg
value is never set, unless I wrap the config block inside an
afterEvaluate
to call the
arg("key", "value")
after the values provided via the custom extension are available.
👍 1
g
Alright make sense, also hopefully it's not required for the OP, but clearly a gradle trick to keep in mind 👌