I have a closure of defined in a another build.gradle file called other.gradle. Here is the contents:
Closure callback = {
productFlavors {
...
devel {
...
}
prod {
...
}
}
}
Now in my build.gradle file I want to call this closure like this:
apply from: 'other.gradle'
productFlavors(callback());
but I keep getting an error that callback() cant be found. Both files are in the same directory. My issue is how do i get the build.gradle file to see the callback closure in the 'other.gradle' file.
It should be done in the following way:
other.gradle
project.ext.callback = { c ->
println(c)
}
build.gradle
apply from: 'other.gradle'
callback('a')
Or in same cases callback
should be referred via project.instance
, e.g. project.callback('a')
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments