I am trying to figure out how to apply a plugin defined in the version catalog to a project?.. I know how to do inside a build script but I am unable to do it via a standalone plugin. below is a crude example of what I am trying to do inside my custom plugin…
I presume I could be discouraged from letting my plugin directly apply the plugins defined in the version catalog onto my project. But this plugin is not meant for widespread adoption but only to be used internally for some of my personal projects…
class BuildSrcPlugin: Plugin<Project> {
override fun apply(project: Project) {
val catalog = project.extensions.getByType<VersionCatalogsExtension>()
val libs: VersionCatalog = catalog.named("libs")
val plugin = libs.findPlugin("my_test_plugin").orElseThrow { RuntimeException("") }
project.plugins.apply(plugin.get().pluginId)
}
}