Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditionally Apply Gradle Plugin

As the title suggests I want to apply a plugin in my build.gradle iff a certain properties file exists in the project folder. The following attempt

buildscript {
    File c = file('crashlytics.properties')
    ext {
        crashlytics = c.exists();
    }
}

if (crashlytics) {
    apply plugin: 'io.fabric'
}
//...

results in the following error message

No such property: verboseGradlePlugin for class: java.lang.Boolean

Is there a way to achieve what I want?

like image 575
Eugen Avatar asked Mar 10 '15 18:03

Eugen


1 Answers

You can try:

if (project.file('crashlytics.properties').exists()) {
   apply plugin: 'io.fabric'
}
like image 137
Opal Avatar answered Oct 23 '22 11:10

Opal