settings.gradle.kts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. include(":app")
  2. include(":domain")
  3. include(":common")
  4. include(":commonAndroid")
  5. include(":test-helpers")
  6. include(":lint-rules")
  7. pluginManagement {
  8. // Leave empty, or only list what a `plugins {}` block in this file needs
  9. }
  10. // Changes to this function must be synced across all duplicates of it (settings.gradle.kts, buildSrc/settings.gradle.kts, buildSrc/build.gradle.kts)
  11. fun RepositoryHandler.dependencyProxy() {
  12. data class ProxyConfig(
  13. val apiV4Url: String?,
  14. val headerName: String,
  15. val token: String?,
  16. )
  17. val ciApiV4Url = providers.environmentVariable("CI_API_V4_URL").orNull
  18. val ciJobToken = providers.environmentVariable("CI_JOB_TOKEN").orNull
  19. val localApiV4Url = providers.gradleProperty("apiV4Url").orNull
  20. val localJobToken = providers.gradleProperty("dependencyProxyPrivateToken").orNull
  21. val config = if (ciApiV4Url != null && ciJobToken != null) {
  22. println("Using dependency proxy with CI config")
  23. ProxyConfig(
  24. apiV4Url = ciApiV4Url,
  25. headerName = "Job-Token",
  26. token = ciJobToken,
  27. )
  28. } else if (!localApiV4Url.isNullOrBlank() && !localJobToken.isNullOrBlank()) {
  29. println("Using dependency proxy with local config")
  30. ProxyConfig(
  31. apiV4Url = providers.gradleProperty("apiV4Url").orNull,
  32. headerName = "Private-Token",
  33. token = providers.gradleProperty("dependencyProxyPrivateToken").orNull,
  34. )
  35. } else {
  36. return
  37. }
  38. val repositoryUri = uri("${config.apiV4Url}/virtual_registries/packages/maven/1")
  39. maven {
  40. url = repositoryUri
  41. name = "GitLab"
  42. credentials(HttpHeaderCredentials::class) {
  43. name = config.headerName
  44. value = config.token
  45. }
  46. authentication {
  47. create<HttpHeaderAuthentication>("header")
  48. }
  49. }
  50. }
  51. gradle.beforeProject {
  52. buildscript.repositories {
  53. dependencyProxy()
  54. google()
  55. mavenCentral()
  56. flatDir { dir("app/libs") }
  57. }
  58. }
  59. settings.pluginManagement.repositories {
  60. dependencyProxy()
  61. gradlePluginPortal()
  62. }
  63. dependencyResolutionManagement {
  64. repositories {
  65. dependencyProxy()
  66. google()
  67. mavenCentral()
  68. flatDir { dir("app/libs") }
  69. // Huawei
  70. exclusiveContent {
  71. forRepository {
  72. maven("https://developer.huawei.com/repo/")
  73. }
  74. filter {
  75. // Only matching dependencies will be installed from this repository.
  76. includeGroup("com.huawei.hms")
  77. includeGroup("com.huawei.android.hms")
  78. includeGroup("com.huawei.hmf")
  79. }
  80. }
  81. }
  82. }