From e722a0282493ff548326c819a572488faf4a494a Mon Sep 17 00:00:00 2001
From: Taras Smakula <tarassmakula@gmail.com>
Date: Thu, 18 Jan 2024 17:20:21 +0200
Subject: [PATCH] Change publishers for all modules

---
 auth/build.gradle    | 39 +++++++++++++--------------------------
 build.gradle         | 24 +-----------------------
 core/build.gradle    | 42 ++++++++++++++----------------------------
 gallery/build.gradle | 40 +++++++++++++---------------------------
 4 files changed, 41 insertions(+), 104 deletions(-)

diff --git a/auth/build.gradle b/auth/build.gradle
index 5ada1a537..55d1706ce 100644
--- a/auth/build.gradle
+++ b/auth/build.gradle
@@ -61,6 +61,12 @@ android {
             version '3.22.1'
         }
     }
+    publishing {
+        singleVariant("release") {
+            withSourcesJar()
+            withJavadocJar()
+        }
+    }
 }
 
 dependencies {
@@ -92,34 +98,15 @@ kapt {
     correctErrorTypes = true
 }
 
-def groupIdString = "org.futo.circles"
-def artifactIdString = "auth-gplay"
+publishing {
+    publications {
+        release(MavenPublication) {
+            groupId = rootProject.ext.modules_groupId
+            artifactId = "auth-gplay"
+            version rootProject.ext.modules_version
 
-afterEvaluate {
-    Properties properties = new Properties()
-    if (rootProject.file("local.properties").exists()) {
-        properties.load(rootProject.file("local.properties").newDataInputStream())
-    }
-    publishing {
-        publications {
-            release(MavenPublication) {
+            afterEvaluate {
                 from components.gplayRelease
-                groupId groupIdString
-                artifactId artifactIdString
-                version rootProject.ext.modules_version
-            }
-        }
-        repositories {
-            maven {
-                url "https://gitlab.futo.org/api/v4/projects/$rootProject.ext.modules_gitlab_projectId/packages/maven"
-                name "GitLab"
-                credentials(HttpHeaderCredentials) {
-                    name = "Private-Token"
-                    value = properties.getProperty("PUBLISH_TOKEN")
-                }
-                authentication {
-                    header(HttpHeaderAuthentication)
-                }
             }
         }
     }
diff --git a/build.gradle b/build.gradle
index d453270a6..3dae198e2 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
         androidx_nav_version = '2.7.6'
         hilt_version = '2.50'
         modules_version = "1.0.9"
-        modules_gitlab_projectId = "13"
+        modules_groupId = "org.futo.gitlab.circles"
     }
     repositories {
         google()
@@ -26,32 +26,10 @@ allprojects {
         google()
         mavenCentral()
         maven { url 'https://jitpack.io' }
-        maven { url 'https://gitlab.futo.org/api/v4/projects/16/packages/maven' }
-        maven { url 'https://gitlab.futo.org/api/v4/projects/13/packages/maven' }
-        maven { url 'https://gitlab.futo.org/api/v4/projects/130/packages/maven' }
     }
 }
 
 
 tasks.register('clean', Delete) {
     delete rootProject.buildDir
-}
-
-tasks.register('cleanBuildPublishModules', GradleBuild) {
-    tasks.register('assembleModulesRelease') {
-        dependsOn 'clean'
-        dependsOn ':core:assembleRelease'
-        dependsOn ':auth:assembleRelease'
-        dependsOn ':gallery:assembleRelease'
-    }
-
-    tasks.register('publishModules') {
-        dependsOn 'assembleModulesRelease'
-        dependsOn ':core:publish'
-        dependsOn ':auth:publish'
-        dependsOn ':gallery:publish'
-    }
-
-    dependsOn 'assembleModulesRelease'
-    dependsOn 'publishModules'
 }
\ No newline at end of file
diff --git a/core/build.gradle b/core/build.gradle
index 1d9fcbfec..ad4b26e5e 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -41,6 +41,12 @@ android {
                 "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
         ]
     }
+    publishing {
+        singleVariant("release") {
+            withSourcesJar()
+            withJavadocJar()
+        }
+    }
 }
 
 dependencies {
@@ -70,7 +76,7 @@ dependencies {
     kapt "com.google.dagger:hilt-compiler:$rootProject.ext.hilt_version"
 
     //Matrix
-    api 'org.matrix.android:matrix-sdk-android:1.6.11'
+    api('org.futo.gitlab.circles:matrix-android-sdk:v1.6.10.8@aar') { transitive = true }
 
     //Retrofit2
     def retrofit_version = '2.9.0'
@@ -121,35 +127,15 @@ kapt {
     correctErrorTypes = true
 }
 
+publishing {
+    publications {
+        release(MavenPublication) {
+            groupId = rootProject.ext.modules_groupId
+            artifactId = "core"
+            version rootProject.ext.modules_version
 
-def groupIdString = "org.futo.circles"
-def artifactIdString = "core"
-
-afterEvaluate {
-    Properties properties = new Properties()
-    if (rootProject.file("local.properties").exists()) {
-        properties.load(rootProject.file("local.properties").newDataInputStream())
-    }
-    publishing {
-        publications {
-            release(MavenPublication) {
+            afterEvaluate {
                 from components.release
-                groupId groupIdString
-                artifactId artifactIdString
-                version rootProject.ext.modules_version
-            }
-        }
-        repositories {
-            maven {
-                url "https://gitlab.futo.org/api/v4/projects/$rootProject.ext.modules_gitlab_projectId/packages/maven"
-                name "GitLab"
-                credentials(HttpHeaderCredentials) {
-                    name = "Private-Token"
-                    value = properties.getProperty("PUBLISH_TOKEN")
-                }
-                authentication {
-                    header(HttpHeaderAuthentication)
-                }
             }
         }
     }
diff --git a/gallery/build.gradle b/gallery/build.gradle
index d5e3b15d4..bb1df6d1d 100644
--- a/gallery/build.gradle
+++ b/gallery/build.gradle
@@ -39,6 +39,12 @@ android {
                 "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
         ]
     }
+    publishing {
+        singleVariant("release") {
+            withSourcesJar()
+            withJavadocJar()
+        }
+    }
 }
 
 dependencies {
@@ -67,35 +73,15 @@ kapt {
 }
 
 
-def groupIdString = "org.futo.circles"
-def artifactIdString = "gallery"
-def publicationName = "release"
+publishing {
+    publications {
+        release(MavenPublication) {
+            groupId = rootProject.ext.modules_groupId
+            artifactId = "gallery"
+            version rootProject.ext.modules_version
 
-afterEvaluate {
-    Properties properties = new Properties()
-    if (rootProject.file("local.properties").exists()) {
-        properties.load(rootProject.file("local.properties").newDataInputStream())
-    }
-    publishing {
-        publications {
-            "$publicationName"(MavenPublication) {
+            afterEvaluate {
                 from components.release
-                groupId groupIdString
-                artifactId artifactIdString
-                version rootProject.ext.modules_version
-            }
-        }
-        repositories {
-            maven {
-                url "https://gitlab.futo.org/api/v4/projects/$rootProject.ext.modules_gitlab_projectId/packages/maven"
-                name "GitLab"
-                credentials(HttpHeaderCredentials) {
-                    name = "Private-Token"
-                    value = properties.getProperty("PUBLISH_TOKEN")
-                }
-                authentication {
-                    header(HttpHeaderAuthentication)
-                }
             }
         }
     }
-- 
GitLab