A Gradle init script plugin that dynamically updates buildscript and project repositories to use the configured mirror URLs.
The repository-mirrors-gradle-plugin is available in the Gradle Plugin Portal.
To apply the plugin to all projects on your workstation or build server automatically, update the Gradle init script below with your own Artifactory URL, and save it to $HOME/.gradle/init.d/repositoryMirrors.gradle
.
initscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath "co.insecurity:repository-mirrors-gradle-plugin:0.4.2"
}
}
apply plugin: co.insecurity.gradle.repository_mirrors.RepositoryMirrorsPlugin
allprojects {
repositoryMirrors {
artifactoryURL = 'https://repo.jfrog.org/artifactory'
// read timeout in milliseconds; when readTimeout > 0, a warning will be emitted if exceeded while
// reading response from Artifactory server and configured repos will be left unmodified;
// otherwise, if readTimeout <= 0, wait for the server to respond indefinitely
// (default: 5000ms)
readTimeout = 10000
// connection timeout in milliseconds; when connectTimeout > 0, a warning will be emitted if exceeded while
// connecting to Artifactory server and configured repos will be left unmodified;
// otherwise, if connectTimeout <= 0, wait for the connection to complete indefinitely
// (default: 5000ms)
connectTimeout = 5000
failOnTimeout = false // fail build on connection timeout to Artifactory server (default: false)
removeDuplicates = true // remove duplicate (i.e. same URL) Ivy and Maven repositories (default: false)
removeMissing = false // remove Ivy and Maven repositories which do not have a mirror (default: false)
enabled = true // when false, plugin execution will be skipped (default: false)
}
}
Once this script is added, the plugin will automatically be applied to all Gradle projects during the configuration phase, and will update each buildscript and project repository URL with its mirror in Artifactory, if one exists.
Without running tests:
./gradlew clean assemble
To run tests:
./gradlew clean test check