Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 1 | /* |
| 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 Viverette | bb04f2e | 2020-04-09 17:13:37 -0400 | [diff] [blame] | 17 | def supportRootFolder = ext.supportRootFolder |
| 18 | if (supportRootFolder == null) { |
| 19 | throw new RuntimeException("Canonical root project directory is not set. You must specify " + |
| 20 | "ext.supportRootFolder before including this script") |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 21 | } |
Alan Viverette | bb04f2e | 2020-04-09 17:13:37 -0400 | [diff] [blame] | 22 | // Makes strong assumptions about the project structure. |
| 23 | def checkoutRoot = supportRootFolder.parentFile.parentFile |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 24 | |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 25 | ext.repos = new Properties() |
Alan Viverette | bb04f2e | 2020-04-09 17:13:37 -0400 | [diff] [blame] | 26 | ext.repos.checkoutRoot = checkoutRoot.absolutePath |
| 27 | ext.repos.prebuiltsRoot = new File(checkoutRoot, "prebuilts").absolutePath |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 28 | |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Adds maven repositories to the given repository handler. |
| 31 | */ |
| 32 | def addMavenRepositories(RepositoryHandler handler) { |
Jeff Gaston | 4307875 | 2019-12-06 16:50:35 -0500 | [diff] [blame] | 33 | handler.maven { |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 34 | url("${repos.prebuiltsRoot}/androidx/internal") |
Jeff Gaston | 4307875 | 2019-12-06 16:50:35 -0500 | [diff] [blame] | 35 | metadataSources { |
| 36 | mavenPom() |
| 37 | artifact() |
| 38 | } |
| 39 | content { |
| 40 | includeGroupByRegex "android.*" |
| 41 | includeGroupByRegex "com.android.support.*" |
| 42 | excludeGroupByRegex "androidx.databinding.*" |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 43 | } |
| 44 | } |
Jeff Gaston | 3646f54 | 2019-11-21 14:09:25 -0500 | [diff] [blame] | 45 | 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 Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 48 | url("${repos.prebuiltsRoot}/androidx/external/no-group") |
Jeff Gaston | 3646f54 | 2019-11-21 14:09:25 -0500 | [diff] [blame] | 49 | patternLayout { |
| 50 | artifact("[artifact]/[revision]/[artifact]-[revision].[ext]") |
| 51 | } |
| 52 | metadataSources { |
| 53 | it.artifact() |
| 54 | } |
Jeff Gaston | 4307875 | 2019-12-06 16:50:35 -0500 | [diff] [blame] | 55 | content { |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 56 | includeGroup("") |
Jeff Gaston | 4307875 | 2019-12-06 16:50:35 -0500 | [diff] [blame] | 57 | } |
| 58 | } |
Jeff Gaston | fef185a | 2020-02-05 11:48:53 -0500 | [diff] [blame] | 59 | def buildDokka = System.getenv("BUILD_DOKKA") != null |
Jeff Gaston | 4307875 | 2019-12-06 16:50:35 -0500 | [diff] [blame] | 60 | handler.maven { |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 61 | url("${repos.prebuiltsRoot}/androidx/external") |
Jeff Gaston | 4307875 | 2019-12-06 16:50:35 -0500 | [diff] [blame] | 62 | metadataSources { |
| 63 | mavenPom() |
| 64 | artifact() |
| 65 | } |
Jeff Gaston | fef185a | 2020-02-05 11:48:53 -0500 | [diff] [blame] | 66 | if (buildDokka) { |
| 67 | content { |
| 68 | excludeGroup "org.jetbrains.dokka" |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | if (buildDokka) { |
| 73 | handler.maven { |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 74 | url("${repos.checkoutRoot}/external/dokka/build/dist-maven") |
Jeff Gaston | fef185a | 2020-02-05 11:48:53 -0500 | [diff] [blame] | 75 | content { |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 76 | includeGroup("org.jetbrains.dokka") |
Jeff Gaston | fef185a | 2020-02-05 11:48:53 -0500 | [diff] [blame] | 77 | } |
| 78 | } |
Jeff Gaston | 3646f54 | 2019-11-21 14:09:25 -0500 | [diff] [blame] | 79 | } |
Aurimas Liutikas | bb9f134 | 2020-02-12 09:55:11 -0800 | [diff] [blame] | 80 | if (System.getenv("ALLOW_PUBLIC_REPOS") != null) { |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 81 | handler.mavenCentral() |
| 82 | handler.jcenter() |
Aurimas Liutikas | aa9688e | 2017-07-06 10:41:00 -0700 | [diff] [blame] | 83 | handler.google() |
Aurimas Liutikas | a2cbbfa | 2018-01-25 14:42:41 -0800 | [diff] [blame] | 84 | handler.maven { |
Jim Sproch | 9e38b4f | 2021-01-06 14:21:06 -0800 | [diff] [blame] | 85 | url("https://plugins.gradle.org/m2/") |
Aurimas Liutikas | a2cbbfa | 2018-01-25 14:42:41 -0800 | [diff] [blame] | 86 | } |
Daniel Santiago Rivera | dc2c8e9 | 2020-03-26 17:26:46 +0000 | [diff] [blame] | 87 | handler.mavenLocal() |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 88 | } |
| 89 | def androidPluginRepoOverride = System.getenv("GRADLE_PLUGIN_REPO") |
| 90 | if (androidPluginRepoOverride != null) { |
Chris Warrington | fd398d0 | 2020-05-15 16:37:38 +0000 | [diff] [blame] | 91 | for(extraRepo in androidPluginRepoOverride.split(File.pathSeparator)) { |
| 92 | handler.maven { |
| 93 | url extraRepo |
| 94 | } |
Aurimas Liutikas | 4854124 | 2020-03-04 12:56:08 -0800 | [diff] [blame] | 95 | } |
Aurimas Liutikas | 9ab3b4c3 | 2017-04-19 09:33:27 -0700 | [diff] [blame] | 96 | } |
| 97 | } |
| 98 | |
Aurimas Liutikas | a2cbbfa | 2018-01-25 14:42:41 -0800 | [diff] [blame] | 99 | ext.repos.addMavenRepositories = this.&addMavenRepositories |