Content of helpers/common-methods.gradle: // Define methods as usual def commonMethod1(param){ return true } def commonMethod2(param){ return true } // Export methods by turning them into closures ext{ commonMethod1 = this.&commonMethod1 otherNameForMethod2 = this.&commonMethod2 } And this is how I use those methods in another script: // Use double-quotes, otherwise $ won't work apply from: "http://myhelpers.com/helpers/common-methods.gradle" // You can also use URLs //apply from: "https://bitbucket.org/mb/build_scripts/raw/master/common-methods.gradle" task myBuildTask{ def myVar = commonMethod1("parameter1") otherNameForMethod2(myVar) }
I wanted a place where I can post technical articles only. This is the place to find out my tips and tricks for being a Java web applications developer. I hope it helps you.
No comments:
Post a Comment