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