blob: ba56c7566bf5c834b1ba3d8839f365d765d543a2 [file] [log] [blame]
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
String getFullSdkPath(String prebuiltsRoot) {
final String osName = System.getProperty("os.name").toLowerCase()
final boolean isMacOsX =
osName.contains("mac os x") || osName.contains("darwin") || osName.contains("osx");
final String platform = isMacOsX ? 'darwin' : 'linux'
return "${prebuiltsRoot}/fullsdk-${platform}"
}
def supportRoot = ext.supportRootFolder
if (supportRoot == null) {
throw new RuntimeException("variable supportRootFolder is not set. you must set it before" +
" including this script")
}
apply from: "${supportRoot}/buildSrc/unbundled_check.gradle"
def checkoutRoot = "${ext.supportRootFolder}/../.."
ext.repos = new Properties()
ext.repos.prebuiltsRoot = "${checkoutRoot}/prebuilts"
ext.repos.prebuiltsRootUri = "file://${repos.prebuiltsRoot}"
ext.repoNames = [// Android Gradle Plugin prebuilts updated manually
"${repos.prebuiltsRoot}/gradle-plugin",
// Miscellaneous prebuilts updated sporadically
"${repos.prebuiltsRoot}/tools/common/m2/repository",
// Historical releases updated as part of public release
"${repos.prebuiltsRoot}/maven_repo/android",
// Manually constructed, but soon to be updated by update_current.py
"${repos.prebuiltsRoot}/sdk/current/extras/material-design",
// Full checkout prebuilts updated by update_current.py
"${repos.prebuiltsRoot}/sdk/current/support/m2repository",
// Unbundled checkout prebuilts updated by fullsdk drop
"${getFullSdkPath(repos.prebuiltsRoot)}/extras/m2repository"]
/**
* Adds maven repositories to the given repository handler.
*/
def addMavenRepositories(RepositoryHandler handler) {
repoNames.each { repo ->
handler.maven {
url repo
}
}
if (System.getenv("ALLOW_PUBLIC_REPOS") != null || (isUnbundledBuild(ext.supportRootFolder))) {
handler.mavenCentral()
handler.jcenter()
handler.google()
handler.maven {
url "https://plugins.gradle.org/m2/"
}
}
def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO")
if (androidPluginRepoOverride != null) {
handler.maven {
url androidPluginRepoOverride
}
}
}
ext.repos.addMavenRepositories = this.&addMavenRepositories