blob: 156ec66881c39b9ca0415e876b59919651a4d2cb [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
17import org.gradle.api.artifacts.dsl.RepositoryHandler;
18
Alan Viverette1eefe7a2017-08-14 09:54:56 -040019String 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 Liutikas9ab3b4c2017-04-19 09:33:27 -070027def supportRoot = ext.supportRootFolder
28if (supportRoot == null) {
29 throw new RuntimeException("variable supportRootFolder is not set. you must set it before" +
30 " including this script")
31}
32
33def checkoutRoot = "${supportRoot}/../.."
34ext.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",
40 "${repos.prebuiltsRoot}/tools/common/m2/internal",
Alan Viverette1eefe7a2017-08-14 09:54:56 -040041 "${repos.prebuiltsRoot}/maven_repo/android",
42 "${getFullSdkPath(repos.prebuiltsRoot)}/extras/m2repository"]
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070043
44/**
45 * Adds maven repositories to the given repository handler.
46 */
47def addMavenRepositories(RepositoryHandler handler) {
48 repoNames.each { repo ->
49 handler.maven {
50 url repo
51 }
52 }
53 if (System.getenv("ALLOW_PUBLIC_REPOS") != null) {
54 handler.mavenCentral()
55 handler.jcenter()
Aurimas Liutikasaa9688e2017-07-06 10:41:00 -070056 handler.google()
Aurimas Liutikas9ab3b4c2017-04-19 09:33:27 -070057 }
58 def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO")
59 if (androidPluginRepoOverride != null) {
60 handler.maven {
61 url androidPluginRepoOverride
62 }
63 }
64}
65
66ext.repos.addMavenRepositories = this.&addMavenRepositories