Skip to content

Instantly share code, notes, and snippets.

View yuzd's full-sized avatar
🏠
Working

俞正东 yuzd

🏠
Working
View GitHub Profile
@bennyhuo
bennyhuo / init.gradle.kts
Last active December 2, 2024 10:13
How to config mirrors for repositories in Gradle without changing the source code of your project?
fun RepositoryHandler.enableMirror() {
all {
if (this is MavenArtifactRepository) {
val originalUrl = this.url.toString().removeSuffix("/")
urlMappings[originalUrl]?.let {
logger.lifecycle("Repository[$url] is mirrored to $it")
this.setUrl(it)
}
}
}