I have a build.gradle
file that includes a repository definition in a buildscript
block, like so:
buildscript {
repositories {
// Several proprietary repositories are declared
}
dependencies {
classpath "com.example:foo:1.0"
}
}
apply from: "bar.gradle"
I would like to bar.gradle
to import a class from the foo
dependency. According to this answer, the way to do that is to duplicate the buildscript
block in bar.gradle
.
However, I would like to reduce code duplication because the list of repositories is rather long and might change. Is it possible to have bar.gradle
reference the repositories declared within the parent build.gradle
?
So far, I tried this in bar.gradle
:
buildscript {
repositories {
project.buildscript.repositories
}
dependencies {
classpath "com.example:foo:1.0"
}
}
But unfortunately, I still get an error saying that repositories are not defined.