It looks like this stopped working with 2.0. I’m not sure, but I’m guessing this is related to the Groovy 2.x upgrade. You can work around it using a project extension closure:
Peter - it works perfectly fine in gradle 1.12. i’ve no problem with changing the syntax but there is still something fishy with this. If I define a method
def stage() {
do stuff
}
in the build.gradle file, I can still use it BUT if i move it to another file and import (apply from) I have to convert it to a closure.
Apparently, 1.12 is the only version ever where this worked (I tried 1.0 and everything from 1.9 up). I don’t think this was intentional (don’t recall this feature being announced, and our tests would have caught a regression). ‘ext.stage = { … }’ has always been the official solution (also taught in our training). In general, I agree that it would be nice to have this feature, and it would be interesting to know why it works in 1.12.
No problem. I appreciate the quick responses from you and gary. while thinking about this, i actually refactored the code into a simple plugin which ends up being much cleaner.