Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enforce gradle plugins applying order?

Tags:

gradle

In our company we wrote custom gradle plugin which is doing some stuff when application plugin is present. But when application plugin is included in build.gradle after our plugin, our plugin doesn't discover application plugin and actions are not executed.

Is there any way in gradle to enforce plugin applying order? Or any other solution?

Small excerpt from our plugin:

void apply(Project project) {
        if (project.plugins.hasPlugin(ApplicationPlugin) {
             //some stuff, doesn't work if "application" appears after this plugin
        }
}
like image 528
wjtk Avatar asked Feb 25 '15 23:02

wjtk


1 Answers

According to this thread on the Gradle forums, withType(Class) and withId(String) are lazily evaluated and only applied when the referenced plugin is applied.

void apply(Project project) {
    project.plugins.withType(ApplicationPlugin) {
        //some stuff, doesn't work if "application" appears after this plugin
    }
}
like image 84
Acinyx Avatar answered Oct 08 '22 12:10

Acinyx