From 80a61cf6b51f7cdd779a88f748d797df0343d1f8 Mon Sep 17 00:00:00 2001
From: Benoit Marty <benoit.marty@gmail.com>
Date: Thu, 11 Jul 2019 14:03:20 +0200
Subject: [PATCH] Improve dependency download safe path

---
 build.gradle                    | 24 ++++++++++++++++++------
 matrix-sdk-android/build.gradle |  6 ------
 2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/build.gradle b/build.gradle
index 2817bcef3c..91415088e5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -24,15 +24,27 @@ buildscript {
 
 allprojects {
     repositories {
-        maven { url "http://dl.bintray.com/piasy/maven" }
-        maven { url 'https://jitpack.io' }
+        // For olm library. This has to be declared first, to ensure that Olm library is not downloaded from another repo
+        maven {
+            url 'https://jitpack.io'
+            content {
+                // Use this repo only for olm library
+                includeGroupByRegex "org\\.matrix\\.gitlab\\.matrix-org"
+                // And also for FilePicker
+                includeGroupByRegex "com\\.github\\.jaiselrahman"
+                // And monarchy
+                includeGroupByRegex "com\\.github\\.Zhuinden"
+            }
+        }
+        maven {
+            url "http://dl.bintray.com/piasy/maven"
+            content {
+                includeGroupByRegex "com\\.github\\.piasy"
+            }
+        }
         maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
         google()
         jcenter()
-        // For Olm SDK
-        maven {
-            url 'https://jitpack.io'
-        }
     }
 }
 
diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle
index 2066c5ef16..3eaf43eb69 100644
--- a/matrix-sdk-android/build.gradle
+++ b/matrix-sdk-android/build.gradle
@@ -6,7 +6,6 @@ apply plugin: 'realm-android'
 apply plugin: 'okreplay'
 
 buildscript {
-
     repositories {
         jcenter()
     }
@@ -15,11 +14,6 @@ buildscript {
     }
 }
 
-repositories {
-    google()
-    jcenter()
-}
-
 androidExtensions {
     experimental = true
 }