Aurimas Liutikas | 9ab3b4c | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 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 | |
| 17 | import org.gradle.api.artifacts.dsl.RepositoryHandler; |
| 18 | |
Alan Viverette | 1eefe7a | 2017-08-14 09:54:56 -0400 | [diff] [blame] | 19 | String getFullSdkPath(String prebuiltsRoot) { |
| 20 | final String osName = System.getProperty("os.name").toLowerCase() |
| 21 | final boolean isMacOsX = |
| 22 | osName.contains("mac os x") || osName.contains("darwin") || osName.contains("osx"); |
| 23 | final String platform = isMacOsX ? 'darwin' : 'linux' |
| 24 | return "${prebuiltsRoot}/fullsdk-${platform}" |
| 25 | } |
| 26 | |
Aurimas Liutikas | 9ab3b4c | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 27 | def supportRoot = ext.supportRootFolder |
| 28 | if (supportRoot == null) { |
| 29 | throw new RuntimeException("variable supportRootFolder is not set. you must set it before" + |
| 30 | " including this script") |
| 31 | } |
| 32 | |
| 33 | def checkoutRoot = "${supportRoot}/../.." |
| 34 | ext.repos = new Properties() |
| 35 | ext.repos.prebuiltsRoot = "${checkoutRoot}/prebuilts" |
| 36 | ext.repos.prebuiltsRootUri = "file://${repos.prebuiltsRoot}" |
| 37 | |
| 38 | ext.repoNames = ["${repos.prebuiltsRoot}/gradle-plugin", |
| 39 | "${repos.prebuiltsRoot}/tools/common/m2/repository", |
Alan Viverette | 1eefe7a | 2017-08-14 09:54:56 -0400 | [diff] [blame] | 40 | "${repos.prebuiltsRoot}/maven_repo/android", |
| 41 | "${getFullSdkPath(repos.prebuiltsRoot)}/extras/m2repository"] |
Aurimas Liutikas | 9ab3b4c | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * Adds maven repositories to the given repository handler. |
| 45 | */ |
| 46 | def addMavenRepositories(RepositoryHandler handler) { |
| 47 | repoNames.each { repo -> |
| 48 | handler.maven { |
| 49 | url repo |
| 50 | } |
| 51 | } |
| 52 | if (System.getenv("ALLOW_PUBLIC_REPOS") != null) { |
| 53 | handler.mavenCentral() |
| 54 | handler.jcenter() |
Aurimas Liutikas | aa9688e | 2017-07-06 10:41:00 -0700 | [diff] [blame] | 55 | handler.google() |
Aurimas Liutikas | 9ab3b4c | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 56 | } |
| 57 | def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO") |
| 58 | if (androidPluginRepoOverride != null) { |
| 59 | handler.maven { |
| 60 | url androidPluginRepoOverride |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | ext.repos.addMavenRepositories = this.&addMavenRepositories |