blob: 9b5077d0f8b48f7b201b7a73893b675475033ce8 [file] [log] [blame]
Aurimas Liutikas9ab3b4c32017-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 Viverettebb04f2e2020-04-09 17:13:37 -040017def supportRootFolder = ext.supportRootFolder
18if (supportRootFolder == null) {
19 throw new RuntimeException("Canonical root project directory is not set. You must specify " +
20 "ext.supportRootFolder before including this script")
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070021}
Alan Viverettebb04f2e2020-04-09 17:13:37 -040022// Makes strong assumptions about the project structure.
23def checkoutRoot = supportRootFolder.parentFile.parentFile
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070024
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070025ext.repos = new Properties()
Alan Viverettebb04f2e2020-04-09 17:13:37 -040026ext.repos.checkoutRoot = checkoutRoot.absolutePath
27ext.repos.prebuiltsRoot = new File(checkoutRoot, "prebuilts").absolutePath
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070028
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070029/**
30 * Adds maven repositories to the given repository handler.
31 */
32def addMavenRepositories(RepositoryHandler handler) {
Sam Gilbert72e8f422022-04-13 15:08:53 +000033 def metalavaRepoOverride = System.getenv("METALAVA_REPO")
34 if (metalavaRepoOverride != null) {
35 for(extraRepo in metalavaRepoOverride.split(File.pathSeparator)) {
36 handler.maven {
37 url extraRepo
38 }
39 }
40 }
Jeff Gaston43078752019-12-06 16:50:35 -050041 handler.maven {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080042 url("${repos.prebuiltsRoot}/androidx/internal")
Jeff Gaston43078752019-12-06 16:50:35 -050043 metadataSources {
44 mavenPom()
45 artifact()
46 }
47 content {
48 includeGroupByRegex "android.*"
49 includeGroupByRegex "com.android.support.*"
50 excludeGroupByRegex "androidx.databinding.*"
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070051 }
52 }
Jeff Gaston43078752019-12-06 16:50:35 -050053 handler.maven {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080054 url("${repos.prebuiltsRoot}/androidx/external")
Jeff Gaston43078752019-12-06 16:50:35 -050055 metadataSources {
56 mavenPom()
57 artifact()
58 }
Jeff Gaston3646f542019-11-21 14:09:25 -050059 }
Jeff Gaston5633a812021-08-13 11:34:58 -040060 if (System.getenv("ALLOW_PUBLIC_REPOS") != null || System.getProperty("ALLOW_PUBLIC_REPOS") != null) {
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070061 handler.mavenCentral()
Aurimas Liutikasaa9688e2017-07-06 10:41:00 -070062 handler.google()
Aurimas Liutikas35cec9b2021-11-04 16:11:18 -070063 handler.gradlePluginPortal()
Nikolay Igottia3801092021-05-25 16:43:47 +030064 handler.maven {
65 url("https://maven.pkg.jetbrains.space/public/p/compose/dev")
66 }
Daniel Santiago Riveradc2c8e92020-03-26 17:26:46 +000067 handler.mavenLocal()
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070068 }
Sam Gilbert72e8f422022-04-13 15:08:53 +000069 // Ordering appears to be important: b/229733266
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070070 def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO")
71 if (androidPluginRepoOverride != null) {
Chris Warringtonfd398d02020-05-15 16:37:38 +000072 for(extraRepo in androidPluginRepoOverride.split(File.pathSeparator)) {
73 handler.maven {
74 url extraRepo
75 }
Aurimas Liutikas48541242020-03-04 12:56:08 -080076 }
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070077 }
78}
79
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080080ext.repos.addMavenRepositories = this.&addMavenRepositories