You might also want to look at init-scripts: http://gradle.org/0.9.1/docs/userguide/init_scripts.html or groovy ConfigSlurper: http://mrhaki.blogspot.com/2009/10/groovy-goodness-using-configslurper.html http://mrhaki.blogspot.com/2009/11/gradle-goodness-using-properties-for.html
Ken Sipe | [email protected] | blog: http://kensipe.blogspot.com On Mar 14, 2011, at 6:32 PM, Adam Murdoch wrote: > > On 15/03/2011, at 9:05 AM, Andreas Sahlbach wrote: > >> Hi! >> >> I have a fairly complicated repository setting (depending if I am behind the >> firewall in the office or at home using the internet). What is the best way >> to share the repository entries without dumb copying 20 lines of code from >> the allprojects {} to the buildscript{} ? Can't believe that there isn't a >> more elegant way to do this in groovy... > > Some options: > > 1. use an external script: > > in build.gradle: > > buildscript { > apply from: 'repositories.gradle', to: repositories > } > > allprojects { > apply from: 'repositories.gradle', to: repositories > } > > in repositories.gradle: > > mavenCentral() > mavenRepo urls: '...' > ... > > 2. copy the repositories: > > buildscript { > repositories { > //... define the repositories here ... > } > } > > allprojects { > rootProject.buildscript.repositories.each { > repositories.add(it) > } > } > > 3. configure everything from the root buildscript closure: > > buildscript { > (allprojects*.repositories + [repositories]).each { > configure { > // ... define the repositories here ... > } > } > } > > > > -- > Adam Murdoch > Gradle Developer > http://www.gradle.org > Co-Founder and VP of Engineering, Gradleware Inc. - Gradle Training, Support, > Consulting > http://www.gradleware.com >
