We are having a couple of internal repositories which are password protected. They all have the same readonly username/password so I wanted to reuse it but when I extract method I get weird “closure” exceptions (not a Groovy expert).
maven {
credentials {
username archiva_username
password archiva_password
}
url "http://archiva.abc.com/archiva/repository/public/"
}
maven {
credentials {
username archiva_username
password archiva_password
}
url "http://archiva.abc.com/archiva/repository/fallback/"
}
...
which I wanted to replace with
maven {
credentials getArchiva()
url "http://archiva.abc.com/archiva/repository/public/"
}
maven {
credentials getArchiva()
url "http://archiva.abc.com/archiva/repository/fallback/"
}
...
private Object getArchiva() {
credentials {
username archiva_username
password archiva_password
}
}
But then I get
> Could not find method getArchiva() for arguments [] on org.gradle.api.internal.artifacts.repositories.DefaultMavenArtifactRepository_Decorated@252c65db.
I’m aware that the “builder” is missing context here but I lack some Groovy/Gradle knowledge to make it work.