Use pluginManager.withPlugin instead of checking hasPlugin

MSAL

Replaces if (plugins.hasPlugin("id")) { ... } with pluginManager.withPlugin("id") { ... }. hasPlugin only checks whether the plugin has been applied so far, so the block is silently skipped when the plugin is applied later; withPlugin runs the block whenever the plugin is applied, before or after. Conditions with an else branch, or blocks that return, assign script variables, or refer to names the withPlugin action would shadow, are left unchanged. See don't assume your plugin is applied after another.

org.openrewrite.gradle.migrate.plugins.UseWithPluginInsteadOfHasPlugin
mod run . --recipe=org.openrewrite.gradle.migrate.plugins.UseWithPluginInsteadOfHasPlugin

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.