From 6f3060a46387694ff377fdda5217280401f57bf4 Mon Sep 17 00:00:00 2001
From: Taras <tarassmakula@gmail.com>
Date: Mon, 28 Mar 2022 14:35:15 +0300
Subject: [PATCH] Setup publishing

---
 build.gradle          |  4 ----
 gradle-publish.gradle | 41 ++++++++++++++++++++++++++---------------
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/build.gradle b/build.gradle
index 3c9eec6c..f3d20ddb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -56,7 +56,3 @@ allprojects {
         kotlinOptions.allWarningsAsErrors = false
     }
 }
-
-task clean(type: Delete) {
-    delete rootProject.buildDir
-}
diff --git a/gradle-publish.gradle b/gradle-publish.gradle
index beb70ffe..760b9ce5 100644
--- a/gradle-publish.gradle
+++ b/gradle-publish.gradle
@@ -1,40 +1,51 @@
+apply plugin: 'java'
 apply plugin: 'maven-publish'
 
-def artifactId = "matrix-sdk-android"
-def artifactFilePath = "$buildDir/outputs/aar/${artifactId}-release.aar"
+def groupIdString = "org.matrix.android"
+def artifactIdString = "matrix-sdk-android"
+def versionName = "1.4.4"
+def artifactPath = "matrix-sdk-android/build/outputs/aar/$artifactIdString-release.aar"
 def publicationName = "release"
-
+def projectId = "16"
+def token = "e3yxa-_Duy7xLabSa7_z"
 
 publishing {
     publications {
-        "${publicationName}"(MavenPublication) {
-            groupId "org.matrix.android"
-            artifactId "${artifactId}"
-            version "1.4.4"
-            artifact "${artifactFilePath}"
+        "$publicationName"(MavenPublication) {
+            groupId groupIdString
+            artifactId artifactIdString
+            version versionName
+            artifact artifactPath
 
             // To include project dependencies
             pom.withXml {
                 def dependencies = asNode().appendNode('dependencies')
-                configurations.getByName("${publicationName}CompileClasspath").getResolvedConfiguration().getFirstLevelModuleDependencies().each {
-                    def dependency = dependencies.appendNode('dependency')
-                    dependency.appendNode('groupId', it.moduleGroup)
-                    dependency.appendNode('artifactId', it.moduleName)
-                    dependency.appendNode('version', it.moduleVersion)
+                configurations.implementation.allDependencies.each {
+                    if (it.group != null) {
+                        def dependency = dependencies.appendNode('dependency')
+                        dependency.appendNode('groupId', it.moduleGroup)
+                        dependency.appendNode('artifactId', it.moduleName)
+                        dependency.appendNode('version', it.moduleVersion)
+                    }
                 }
             }
         }
     }
     repositories {
         maven {
-            url "https://gitlab.com/api/v4/projects/16/packages/maven"
+            url "https://gitlab.futo.org/api/v4/projects/$projectId/packages/maven"
+            name "GitLab"
             credentials(HttpHeaderCredentials) {
                 name = "Private-Token"
-                value = "e3yxa-_Duy7xLabSa7_z"
+                value = token
             }
             authentication {
                 header(HttpHeaderAuthentication)
             }
         }
     }
+}
+java {
+    sourceCompatibility = JavaVersion.VERSION_11
+    targetCompatibility = JavaVersion.VERSION_11
 }
\ No newline at end of file
-- 
GitLab