This message was deleted.
# community-support
s
This message was deleted.
t
Javadoc says it could be
project.state.executed
v
Sounds like you shouldn't actually do it. 😄 What's the use-case?
z
I had to do some weird logic here around
plugins.withType
and
plugins.whenObjectAdded
Copy code
rootProject.allprojects {
    // this if/else loop is to workaround some weird gradle lifecycle issues
    // we have verify tasks that ensure this does not cause any problems though
    if (plugins.hasPlugin(ConfigPlugin::class.java)) {
        plugins.withType<ConfigPlugin> {
            action.invoke(
                the<Config_gradle.ModuleConfigPluginExtension>().module.get()
            )
        }
    } else {
        plugins.whenObjectAdded {
            val plugin = this
            if (plugin is ConfigPlugin) {
                afterEvaluate {
                    the<Config_gradle.ModuleConfigPluginExtension>().module.get()
                }
            }
        }
    }
}
Was getting some weird error around calling
afterEvaluate
if I used
plugins.withType
in the second
else
block. I think
withType
leverages
afterEvaluate { }
internally? If that is the case then I could leverage it only instead of
plugins.whenObjectAdded
, I just wasn’t sure
v
No,
withType
should not call
afterEvaluate
. And your construct does not make much sense to me. You ask whether the plugin is applied already and if so, you use the reactive method that works whether the plugin is applied already or not and if it is not applied already you use
whenObjectAdded
and an
afterEvaluate
. This does feel very wrong. Just having the content of the
if
should cover the same cases and be cleaner. Still dirty though, because the JavaDoc of
project.plugins
tells you not to use it. You should instead use
pluginManager.withPlugin
.
💯 1
👍 1
z
ohh.
pluginManager
replaces
plugins
?
that’s probably why I couldn’t find the right API