I'm writing am Android Studio Gradle plugin and one of the things I need to do is iterate over the projects and detect if they are of type Android Application or library (or a non android project like general java libs).
I tried to use the following code but it doesn't work properly (detects the application but not libraries):
import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin
...
public void getVariants(){
...
def hasApp = p.plugins.withType(AppPlugin)
def hasLib = p.plugins.withType(LibraryPlugin)
...
}
Are there any other proper ways in Groovy script to detect of a project is of type library ?