Check for Gradle Module Plugin Application
I'm working on a framework with a gradle plugin.
I've decided that the main way to determine the existence of my framework within a gradle module is to check whether the module applies my Gradle Plugin.
It seems the Android plugin does something similar, when you include the below code in build.gradle.kts
, Android Studio marks the module as a Android Module. I think this is done via a Facet.plugins {
id("com.android.application")
}
I would like to do something similar, but for my own gradle plugin.
I've tried looking into the External System, Gradle Plugin, and Android Plugin, but I couldn't find any way to determine whether a plugin is explicitly or transitively (via something like buildSrc gradle projects) included in a gradle module.
Help here would be extremely appreciated.
Thank you!
请先登录再写评论。
Hi,
Currently, we do not provide a straightforward API for this. You are welcome to request it at https://youtrack.jetbrains.com/issues/IJPL but there are no guarantees about implementation and time.
There are workarounds to this, though:
It is possible to gather all the required information from the daemon and then use it on the idea's side.
This approach is used by Android Studio and Kotlin plugin.
GradleExtensionsSettings.getInstance(project)
and then filter the required plugin by fully qualified domain name of the extension class.Hi Karol, thanks so much for this detailed response!
Does Kotlin and Android use this to do Facet Detection? I can't find the implementation on where they detect and apply the Facets.