Functions - pford68/gradle-examples GitHub Wiki

Standalone Functions

def <function name>(<params...>) {
  // body
}

Project Methods

ext.<method name> = {param1, param2, etc. ->
  // body
}

Examples

// In one gradle file
ext.includeAnotherBuild = {
   ...
}

// In another gradle file, simply invoke the method.
includeAnotherBuild()
task myTask {
    ext.myMethod = { param1, param2 ->
        // Method body here
    }

    doLast {
        myMethod(p1, p2) // This will resolve 'myMethod' defined in task
    }
}
⚠️ **GitHub.com Fallback** ⚠️