Skip to content

Instantly share code, notes, and snippets.

@hyongbai
Last active August 21, 2018 06:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyongbai/24887a1b5e111c4ea2d122e2dc9cd0f9 to your computer and use it in GitHub Desktop.
Save hyongbai/24887a1b5e111c4ea2d122e2dc9cd0f9 to your computer and use it in GitHub Desktop.
// Way 1
def loadConfig; loadConfig = { p ->
if (p == null || !p.exists()) return
if (new File(p, "rp-config.gradle").exists()) apply from: "${p}/rp-config.gradle"
else loadConfig(p.parentFile)
}
loadConfig(buildscript.sourceFile.parentFile)
// Way2
def loadConfig = { p ->
if (p == null || !p.exists()) return
if (new File(p, "rp-config.gradle").exists()) apply from: "${p}/rp-config.gradle"
else call(p.parentFile)
}
loadConfig(buildscript.sourceFile.parentFile)
// Way 3
{ p ->
if (p == null || !p.exists()) return
if (new File(p, "rp-config.gradle").exists()) apply from: "${p}/rp-config.gradle"
else call(p.parentFile)
}(buildscript.sourceFile.parentFile)
// Way 4
{ p, cfg = "rp-config.gradle" ->
if (p == null || !p.exists()) return
if (!new File(p, cfg).exists()) call(p.parentFile)
else apply from: "${p}/${cfg}"
}(buildscript.sourceFile.parentFile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment