[go: nahoru, domu]

blob: a882adba5a65c7961a5608d5167cd0b91a84f9c4 [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) {
Jeff Gaston43078752019-12-06 16:50:35 -050033 handler.maven {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080034 url("${repos.prebuiltsRoot}/androidx/internal")
Jeff Gaston43078752019-12-06 16:50:35 -050035 metadataSources {
36 mavenPom()
37 artifact()
38 }
39 content {
40 includeGroupByRegex "android.*"
41 includeGroupByRegex "com.android.support.*"
42 excludeGroupByRegex "androidx.databinding.*"
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070043 }
44 }
Jeff Gaston3646f542019-11-21 14:09:25 -050045 handler.ivy {
46 // TODO: maybe we can move this no-group ivy repo directly into prebuilts/androidx/external
47 // once https://youtrack.jetbrains.com/issue/KT-35049 gets resolved */
Jim Sproch9e38b4f2021-01-06 14:21:06 -080048 url("${repos.prebuiltsRoot}/androidx/external/no-group")
Jeff Gaston3646f542019-11-21 14:09:25 -050049 patternLayout {
50 artifact("[artifact]/[revision]/[artifact]-[revision].[ext]")
51 }
52 metadataSources {
53 it.artifact()
54 }
Jeff Gaston43078752019-12-06 16:50:35 -050055 content {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080056 includeGroup("")
Jeff Gaston43078752019-12-06 16:50:35 -050057 }
58 }
Jeff Gastonfef185a2020-02-05 11:48:53 -050059 def buildDokka = System.getenv("BUILD_DOKKA") != null
Jeff Gaston43078752019-12-06 16:50:35 -050060 handler.maven {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080061 url("${repos.prebuiltsRoot}/androidx/external")
Jeff Gaston43078752019-12-06 16:50:35 -050062 metadataSources {
63 mavenPom()
64 artifact()
65 }
Jeff Gastonfef185a2020-02-05 11:48:53 -050066 if (buildDokka) {
67 content {
68 excludeGroup "org.jetbrains.dokka"
69 }
70 }
71 }
72 if (buildDokka) {
73 handler.maven {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080074 url("${repos.checkoutRoot}/external/dokka/build/dist-maven")
Jeff Gastonfef185a2020-02-05 11:48:53 -050075 content {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080076 includeGroup("org.jetbrains.dokka")
Jeff Gastonfef185a2020-02-05 11:48:53 -050077 }
78 }
Jeff Gaston3646f542019-11-21 14:09:25 -050079 }
Aurimas Liutikasbb9f1342020-02-12 09:55:11 -080080 if (System.getenv("ALLOW_PUBLIC_REPOS") != null) {
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070081 handler.mavenCentral()
82 handler.jcenter()
Aurimas Liutikasaa9688e2017-07-06 10:41:00 -070083 handler.google()
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080084 handler.maven {
Jim Sproch9e38b4f2021-01-06 14:21:06 -080085 url("https://plugins.gradle.org/m2/")
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080086 }
Daniel Santiago Riveradc2c8e92020-03-26 17:26:46 +000087 handler.mavenLocal()
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070088 }
89 def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO")
90 if (androidPluginRepoOverride != null) {
Chris Warringtonfd398d02020-05-15 16:37:38 +000091 for(extraRepo in androidPluginRepoOverride.split(File.pathSeparator)) {
92 handler.maven {
93 url extraRepo
94 }
Aurimas Liutikas48541242020-03-04 12:56:08 -080095 }
Aurimas Liutikas9ab3b4c32017-04-19 09:33:27 -070096 }
97}
98
Aurimas Liutikasa2cbbfa2018-01-25 14:42:41 -080099ext.repos.addMavenRepositories = this.&addMavenRepositories