Imagine you have a gradle build with a gradle subproject. This subproject has some applied script plugin which define their own repositories like this:
buildscript {
repositories {
//jcenter()
maven {
url 'https://example.com/plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.3'
}
}
Now imagine you only own the main project, not the sub project (it is a git submodule).
How can you override the repository definitions of the subproject from the main project?
PS: if you need a better description of the subproject, here it is: https://github.com/docToolchain/docToolchain
Update: I've created an example to paly around with: https://github.com/rdmueller/SO56283254/blob/master/README.adoc
see the readme for more details
I believe I have a solution for the scenario described in the question (but note the caveat below!). You can put something like the following into your settings.gradle
file of the root project:
gradle.allprojects { project ->
if (project.path == ':subproject') {
project.buildscript.repositories { repos ->
all { repo ->
// filtering by repo name here; you could certainly also use
// the URL or other properties
if (repo.name == 'maven') {
remove repo
// TODO replace with the repo you need here:
mavenCentral()
}
}
}
}
}
As M.Ricciuti’s answer says, the caveat is that this won’t work for buildscript repositories in script plugins like the one you apply to the subproject of your sample GitHub project (apply from: 'scripts/AsciiDocBasics.gradle'
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With