1/* 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17import org.gradle.api.artifacts.dsl.RepositoryHandler; 18 19def supportRoot = ext.supportRootFolder 20if (supportRoot == null) { 21 throw new RuntimeException("variable supportRootFolder is not set. you must set it before" + 22 " including this script") 23} 24 25def checkoutRoot = "${supportRoot}/../.." 26ext.repos = new Properties() 27ext.repos.prebuiltsRoot = "${checkoutRoot}/prebuilts" 28ext.repos.prebuiltsRootUri = "file://${repos.prebuiltsRoot}" 29 30ext.repoNames = ["${repos.prebuiltsRoot}/gradle-plugin", 31 "${repos.prebuiltsRoot}/tools/common/m2/repository", 32 "${repos.prebuiltsRoot}/tools/common/m2/internal", 33 "${repos.prebuiltsRoot}/maven_repo/android"] 34 35/** 36 * Adds maven repositories to the given repository handler. 37 */ 38def addMavenRepositories(RepositoryHandler handler) { 39 repoNames.each { repo -> 40 handler.maven { 41 url repo 42 } 43 } 44 if (System.getenv("ALLOW_PUBLIC_REPOS") != null) { 45 handler.mavenCentral() 46 handler.jcenter() 47 } 48 def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO") 49 if (androidPluginRepoOverride != null) { 50 handler.maven { 51 url androidPluginRepoOverride 52 } 53 } 54} 55 56ext.repos.addMavenRepositories = this.&addMavenRepositories