Slackbot
03/10/2022, 12:58 AMThomas Broyer
03/10/2022, 8:19 AMproject.state.executedVampire
03/10/2022, 9:39 AMZak Taccardi
03/12/2022, 2:22 AMplugins.withType and plugins.whenObjectAdded
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 sureVampire
03/12/2022, 4:21 AMwithType 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.Zak Taccardi
03/21/2022, 7:57 PMpluginManager replaces plugins?Zak Taccardi
03/21/2022, 7:57 PM