Skip to content Skip to sidebar Skip to footer

Use Gradle Function From Other Gradle File

I want to split my 300 lines build.gradle logically into multiple build files to make it easier to maintain and extend. As I've noticed, it is possible to split gradle tasks into m

Solution 1:

It's not possible to be done with functions, but if you turn the functions into closures the following example will work well:

lol.gradle

project.ext.lolFunction = {
   println it
}

build.gradle

apply from: 'lol.gradle'

ext.lolFunction(1)                                                             

Solution 2:

See 59.4 at https://docs.gradle.org/current/userguide/organizing_build_logic.html

You can move your functions to a

buildSrc

directory.


Post a Comment for "Use Gradle Function From Other Gradle File"