In Kotlin script gradle I’m trying to: ```plugins....
# android
s
In Kotlin script gradle I’m trying to:
Copy code
plugins.withId("com.android.library") {
    configure<LibraryPlugin> {
        android {
        }
    }
}
but I can’t resolve
android { }
in my build script. What do I need to configure in order to resolve this?
This seems to have worked:
Copy code
if (plugins.hasPlugin("com.android.library")) {
        configure<com.android.build.gradle.LibraryExtension> {
g
Better to use withPlugin, it will be executed when plugin is applied, hasPlugin will have issues with the late plugin application and order dependant
s
I’m not using this from a
subprojects
block. It’s something I’m choosing to opt into for each project
g
Even in this case it's better to use withPlugin
v
Gildor is fully right about better using
pluginManager.withPlugin
. Actually using
plugins.
It's always bad, if you look at the JavaDoc of the
getPlugins
method. And to answer your actual question, accessors are only generated for plugins applied using the
plugins
block in normal build scripts and in precompiled script plugins. In all other cases you have to go by name or type as you did now.