Skip to content

Instantly share code, notes, and snippets.

@martinda
Last active August 29, 2015 14:22
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 martinda/31efb7dfc0bd2ac0715a to your computer and use it in GitHub Desktop.
Save martinda/31efb7dfc0bd2ac0715a to your computer and use it in GitHub Desktop.
gradle example for environments
class Environment {
String url
String name
Environment(String name) {
this.name = name
}
}
class MyExtension {
def project
def environments
def password
MyExtension(Project project) {
this.project = project
this.environments = project.container(Environment)
}
void environments(Closure config) {
environments.configure(config)
}
}
extensions.create('apptree',MyExtension, project)
apptree {
password = 'bar'
environments {
foo {
url = "http://foo.org"
}
bar {
url = "http://bar.org"
}
}
}
apptree.environments.foo.url = 'soeth'
apptree.environments.all {
task "print$it.name"() {
doLast {
println url
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment