diff --git a/build.gradle b/build.gradle
index f4ef35a2608ff753634ca2d5ff0f53a89bd4aa0b..59972ea02cf28f0cb10774a28b57019b91daa876 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,10 +2,10 @@
 
 buildscript {
     apply from: 'dependencies.gradle'
+    apply from: 'dependencies_groups.gradle'
 
     repositories {
         google()
-        jcenter()
         maven {
             url "https://plugins.gradle.org/m2/"
         }
@@ -22,18 +22,40 @@ buildscript {
 
 allprojects {
     repositories {
-        // For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
+        // For olm library.
+        maven {
+            url 'https://gitlab.matrix.org/api/v4/projects/27/packages/maven'
+            content {
+                groups.olm.regex.each { includeGroupByRegex it }
+                groups.olm.group.each { includeGroup it }
+            }
+        }
         maven {
             url 'https://jitpack.io'
             content {
-                // Use this repo only for olm library
-                includeGroupByRegex "org\\.matrix\\.gitlab\\.matrix-org"
-                // And monarchy
-                includeGroupByRegex "com\\.github\\.Zhuinden"
+                groups.jitpack.regex.each { includeGroupByRegex it }
+                groups.jitpack.group.each { includeGroup it }
+            }
+        }
+        google {
+            content {
+                groups.google.regex.each { includeGroupByRegex it }
+                groups.google.group.each { includeGroup it }
+            }
+        }
+        mavenCentral {
+            content {
+                groups.mavenCentral.regex.each { includeGroupByRegex it }
+                groups.mavenCentral.group.each { includeGroup it }
+            }
+        }
+        //noinspection JcenterRepositoryObsolete
+        jcenter {
+            content {
+                groups.jcenter.regex.each { includeGroupByRegex it }
+                groups.jcenter.group.each { includeGroup it }
             }
         }
-        google()
-        jcenter()
     }
 
     tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {