blob: ba56c7566bf5c834b1ba3d8839f365d765d543a2 [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 Liutikasa2cbbfa2018-01-25 14:42:41 -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
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080038ext.repoNames = [// Android Gradle Plugin prebuilts updated manually
39 "${repos.prebuiltsRoot}/gradle-plugin",
40 // Miscellaneous prebuilts updated sporadically
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070041 "${repos.prebuiltsRoot}/tools/common/m2/repository",
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080042 // Historical releases updated as part of public release
Alan Viverette1eefe7a2017-08-14 09:54:56 -040043 "${repos.prebuiltsRoot}/maven_repo/android",
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080044 // Manually constructed, but soon to be updated by update_current.py
45 "${repos.prebuiltsRoot}/sdk/current/extras/material-design",
46 // Full checkout prebuilts updated by update_current.py
47 "${repos.prebuiltsRoot}/sdk/current/support/m2repository",
48 // Unbundled checkout prebuilts updated by fullsdk drop
Alan Viverette1eefe7a2017-08-14 09:54:56 -040049 "${getFullSdkPath(repos.prebuiltsRoot)}/extras/m2repository"]
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070050
51/**
52 * Adds maven repositories to the given repository handler.
53 */
54def addMavenRepositories(RepositoryHandler handler) {
55 repoNames.each { repo ->
56 handler.maven {
57 url repo
58 }
59 }
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080060 if (System.getenv("ALLOW_PUBLIC_REPOS") != null || (isUnbundledBuild(ext.supportRootFolder))) {
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070061 handler.mavenCentral()
62 handler.jcenter()
Aurimas Liutikasaa9688e2017-07-06 10:41:00 -070063 handler.google()
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080064 handler.maven {
65 url "https://plugins.gradle.org/m2/"
66 }
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070067 }
68 def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO")
69 if (androidPluginRepoOverride != null) {
70 handler.maven {
71 url androidPluginRepoOverride
72 }
73 }
74}
75
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080076ext.repos.addMavenRepositories = this.&addMavenRepositories