/*
 * Copyright 2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

val gradleMirrorUrl = findMirrorUrls()["gradle"]
if (gradleMirrorUrl != null) {
    allprojects {
        buildscript {
            repositories {
                maven {
                    name = "gradle-mirror"
                    url = uri(gradleMirrorUrl)
                }
            }
        }
        repositories {
            maven {
                name = "gradle-mirror"
                url = uri(gradleMirrorUrl)
            }
        }
    }
}

fun findMirrorUrls(): Map<String, String> =
    System.getenv("REPO_MIRROR_URLS")?.split(',')?.associate { nameToUrl ->
        val (name, url) = nameToUrl.split(':', limit = 2)
        name to url
    } ?: emptyMap()

Define init script to use internal mirror for Gradle build
Define init script to use internal mirror for Gradle build

lsmaira/gradle,blindpirate/gradle,gradle/gradle,gradle/gradle,lsmaira/gradle,robinverduijn/gradle,robinverduijn/gradle,robinverduijn/gradle,blindpirate/gradle,blindpirate/gradle,lsmaira/gradle,robinverduijn/gradle,lsmaira/gradle,robinverduijn/gradle,robinverduijn/gradle,gradle/gradle,lsmaira/gradle,robinverduijn/gradle,lsmaira/gradle,robinverduijn/gradle,gradle/gradle,gradle/gradle,gradle/gradle,blindpirate/gradle,gradle/gradle,blindpirate/gradle,robinverduijn/gradle,gradle/gradle,lsmaira/gradle,blindpirate/gradle,lsmaira/gradle,robinverduijn/gradle,lsmaira/gradle,blindpirate/gradle,gradle/gradle,robinverduijn/gradle,lsmaira/gradle,blindpirate/gradle,gradle/gradle,blindpirate/gradle,blindpirate/gradle