I have a precompiled script plugin I include as a ...
# gradle
p
I have a precompiled script plugin I include as a composite build. That plugin is both applied to kotlin jvm and the kotlin android plugins. Now this line fails on configuration:
Copy code
dependencies {
  implementation(libs.dagger.runtime)
}
With:
Copy code
Could not find method implementation() for arguments [provider(?)]
Is there any way to fix this without moving it to afterEvaluate?
t
use
"implementation"(libs.dagger.runtime)
p
It doesn't work with add("implementation", x.y.z) either because the configuration is not found
Also interesting: This only happened after moving the plugin from buildSrc to a composite build
v
afterEvaluate
probably wouldn't help either except if you use Groovy DSL, as the accessor would still not be there and thus not compile
If you want to use the accessors, a plugin that adds the respective thing has to be added in the same precompiled script plugin plugins block and that's the same in
buildSrc
p
It's groovy
v
Oh, ok, unexpected on the Kotlin server. :-D
What you need is to be reactive
p
Yeah in kotlin it's the same with add
v
Use
Copy code
pluginManager.withPlugin('theplugintoreactto') {
   implementation...
}
Then the block is only executed if that plugin is applied and not before it is applied.
The other (worse) option would be to make sure it gets applied after the plugin that adds this configuration
p
Thanks, that works!
Then I can go back to kts, these dynamically things are just simpler in groovy :)