blob: 8b0890b0efa749d206cb99c120be255119be1a45 [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 Gaston3646f542019-11-21 14:09:25 -050053 handler.ivy {
54 // TODO: maybe we can move this no-group ivy repo directly into prebuilts/androidx/external
55 // once https://youtrack.jetbrains.com/issue/KT-35049 gets resolved */
Jim Sproch9e38b4f2021-01-06 14:21:06 -080056 url("${repos.prebuiltsRoot}/androidx/external/no-group")
Jeff Gaston3646f542019-11-21 14:09:25 -050057 patternLayout {
58 artifact("[artifact]/[revision]/[artifact]-[revision].[ext]")
59 }
60 metadataSources {
61 it.artifact()
62 }
Jeff Gaston43078752019-12-06 16:50:35 -050063 content {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080064 includeGroup("")
Jeff Gaston43078752019-12-06 16:50:35 -050065 }
66 }
67 handler.maven {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080068 url("${repos.prebuiltsRoot}/androidx/external")
Jeff Gaston43078752019-12-06 16:50:35 -050069 metadataSources {
70 mavenPom()
71 artifact()
72 }
Jeff Gaston3646f542019-11-21 14:09:25 -050073 }
Jeff Gaston5633a812021-08-13 11:34:58 -040074 if (System.getenv("ALLOW_PUBLIC_REPOS") != null || System.getProperty("ALLOW_PUBLIC_REPOS") != null) {
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070075 handler.mavenCentral()
Aurimas Liutikasaa9688e2017-07-06 10:41:00 -070076 handler.google()
Aurimas Liutikas35cec9b2021-11-04 16:11:18 -070077 handler.gradlePluginPortal()
Nikolay Igottia3801092021-05-25 16:43:47 +030078 handler.maven {
79 url("https://maven.pkg.jetbrains.space/public/p/compose/dev")
80 }
Daniel Santiago Riveradc2c8e92020-03-26 17:26:46 +000081 handler.mavenLocal()
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070082 }
Sam Gilbert72e8f422022-04-13 15:08:53 +000083 // Ordering appears to be important: b/229733266
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070084 def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO")
85 if (androidPluginRepoOverride != null) {
Chris Warringtonfd398d02020-05-15 16:37:38 +000086 for(extraRepo in androidPluginRepoOverride.split(File.pathSeparator)) {
87 handler.maven {
88 url extraRepo
89 }
Aurimas Liutikas48541242020-03-04 12:56:08 -080090 }
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070091 }
92}
93
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080094ext.repos.addMavenRepositories = this.&addMavenRepositories