blob: 9785a747a0866847cee1b6f019e7455f2b092cf1 [file] [log] [blame]
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -07001/*
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
Alan Viverette1eefe7a2017-08-14 09:54:56 -040017String getFullSdkPath(String prebuiltsRoot) {
18 final String osName = System.getProperty("os.name").toLowerCase()
19 final boolean isMacOsX =
20 osName.contains("mac os x") || osName.contains("darwin") || osName.contains("osx");
21 final String platform = isMacOsX ? 'darwin' : 'linux'
22 return "${prebuiltsRoot}/fullsdk-${platform}"
23}
24
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070025def supportRoot = ext.supportRootFolder
26if (supportRoot == null) {
27 throw new RuntimeException("variable supportRootFolder is not set. you must set it before" +
28 " including this script")
29}
30
Aurimas Liutikas7fa54122018-01-18 14:13:27 -080031apply from: "${supportRoot}/buildSrc/unbundled_check.gradle"
32
33def checkoutRoot = "${ext.supportRootFolder}/../.."
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070034ext.repos = new Properties()
35ext.repos.prebuiltsRoot = "${checkoutRoot}/prebuilts"
36ext.repos.prebuiltsRootUri = "file://${repos.prebuiltsRoot}"
37
38ext.repoNames = ["${repos.prebuiltsRoot}/gradle-plugin",
39 "${repos.prebuiltsRoot}/tools/common/m2/repository",
Alan Viverette1eefe7a2017-08-14 09:54:56 -040040 "${repos.prebuiltsRoot}/maven_repo/android",
41 "${getFullSdkPath(repos.prebuiltsRoot)}/extras/m2repository"]
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070042
43/**
44 * Adds maven repositories to the given repository handler.
45 */
46def addMavenRepositories(RepositoryHandler handler) {
47 repoNames.each { repo ->
48 handler.maven {
49 url repo
50 }
51 }
Aurimas Liutikas7fa54122018-01-18 14:13:27 -080052 if (System.getenv("ALLOW_PUBLIC_REPOS") != null || (isUnbundledBuild(ext.supportRootFolder))) {
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070053 handler.mavenCentral()
54 handler.jcenter()
Aurimas Liutikasaa9688e2017-07-06 10:41:00 -070055 handler.google()
Aurimas Liutikas7fa54122018-01-18 14:13:27 -080056 handler.maven {
57 url "https://plugins.gradle.org/m2/"
58 }
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070059 }
60 def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO")
61 if (androidPluginRepoOverride != null) {
62 handler.maven {
63 url androidPluginRepoOverride
64 }
65 }
66}
67
68ext.repos.addMavenRepositories = this.&addMavenRepositories