Skip to content

Instantly share code, notes, and snippets.

@itzg
Last active December 30, 2015 22:32
Show Gist options
  • Save itzg/9892449 to your computer and use it in GitHub Desktop.
Save itzg/9892449 to your computer and use it in GitHub Desktop.
This snippet shows how to leverage decoupled, multi-project builds in Gradle.
def sibling = { group, name, version ->
try {
def dep = project(":$name")
if (dep.version == version) {
logger.info("Using locally checked out $group:$name")
return dep
}
logger.debug("Version mismatch for $group:$name, expected $version but had ${dep.version}")
} catch (UnknownProjectException e) {
logger.debug("Project $group:$name was missing")
}
logger.info("Using external dependency $group:$name")
return "$group:$name:$version"
}
dependencies {
compile sibling(typesGroup, 'my-types', myTypesVersion)
// Amd with a dependency customizing closure...NOTE the comma after sibling(...)
compile sibling(libGroup, 'my-lib', myLibVersion), {
exclude group:'log4j', module:'log4j'
}
}
['my-lib','my-types'].each { sibling ->
if (file("../$sibling").exists()) {
includeFlat sibling
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment