From b9bceee8a2ebb4f6631b8c0a9228a23819d527f9 Mon Sep 17 00:00:00 2001
From: Taras <tarassmakula@gmail.com>
Date: Mon, 28 Mar 2022 12:52:00 +0300
Subject: [PATCH] Publish draft

---
 .idea/codeStyles/Project.xml    | 18 ---------------
 .idea/compiler.xml              |  2 +-
 .idea/misc.xml                  |  2 +-
 build.gradle                    | 10 +--------
 dependencies.gradle             |  2 +-
 gradle-publish.gradle           | 40 +++++++++++++++++++++++++++++++++
 matrix-sdk-android/build.gradle |  2 --
 7 files changed, 44 insertions(+), 32 deletions(-)
 create mode 100644 gradle-publish.gradle

diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 0d156937..681f41ae 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -1,23 +1,5 @@
 <component name="ProjectCodeStyleConfiguration">
   <code_scheme name="Project" version="173">
-    <JetCodeStyleSettings>
-      <option name="PACKAGES_TO_USE_STAR_IMPORTS">
-        <value>
-          <package name="java.util" alias="false" withSubpackages="false" />
-          <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
-          <package name="io.ktor" alias="false" withSubpackages="true" />
-        </value>
-      </option>
-      <option name="PACKAGES_IMPORT_LAYOUT">
-        <value>
-          <package name="" alias="false" withSubpackages="true" />
-          <package name="java" alias="false" withSubpackages="true" />
-          <package name="javax" alias="false" withSubpackages="true" />
-          <package name="kotlin" alias="false" withSubpackages="true" />
-          <package name="" alias="true" withSubpackages="true" />
-        </value>
-      </option>
-    </JetCodeStyleSettings>
     <codeStyleSettings language="XML">
       <indentOptions>
         <option name="CONTINUATION_INDENT_SIZE" value="4" />
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index a0af1d1a..fb7f4a8a 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="CompilerConfiguration">
-    <bytecodeTargetLevel target="12" />
+    <bytecodeTargetLevel target="11" />
   </component>
 </project>
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index e394c073..360e6d41 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ExternalStorageConfigurationManager" enabled="true" />
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_12" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="1.8" project-jdk-type="JavaSDK">
     <output url="file://$PROJECT_DIR$/build/classes" />
   </component>
   <component name="ProjectType">
diff --git a/build.gradle b/build.gradle
index 7d9c37b7..3c9eec6c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,6 +3,7 @@
 buildscript {
     apply from: 'dependencies.gradle'
     apply from: 'dependencies_groups.gradle'
+    apply from: 'gradle-publish.gradle'
 
     repositories {
         google()
@@ -14,7 +15,6 @@ buildscript {
     dependencies {
         classpath libs.gradle.gradlePlugin
         classpath libs.gradle.kotlinPlugin
-        classpath 'com.vanniktech:gradle-maven-publish-plugin:0.18.0'
         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
@@ -55,14 +55,6 @@ allprojects {
         // Ignore on the SDK for the moment
         kotlinOptions.allWarningsAsErrors = false
     }
-
-    plugins.withId("com.vanniktech.maven.publish") {
-        // Publish on s01.oss.sonatype.org
-        //https://github.com/vanniktech/gradle-maven-publish-plugin#where-to-upload-to
-        mavenPublish {
-            sonatypeHost = "S01"
-        }
-    }
 }
 
 task clean(type: Delete) {
diff --git a/dependencies.gradle b/dependencies.gradle
index 660457c3..87b8e3c1 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -15,7 +15,7 @@ def dagger = "2.40.5"
 def retrofit = "2.9.0"
 def arrow = "0.8.2"
 def markwon = "4.6.2"
-def moshi = "1.13.0"
+def moshi = "1.12.0"
 def lifecycle = "2.4.0"
 def flowBinding = "1.2.0"
 def epoxy = "4.6.2"
diff --git a/gradle-publish.gradle b/gradle-publish.gradle
new file mode 100644
index 00000000..beb70ffe
--- /dev/null
+++ b/gradle-publish.gradle
@@ -0,0 +1,40 @@
+apply plugin: 'maven-publish'
+
+def artifactId = "matrix-sdk-android"
+def artifactFilePath = "$buildDir/outputs/aar/${artifactId}-release.aar"
+def publicationName = "release"
+
+
+publishing {
+    publications {
+        "${publicationName}"(MavenPublication) {
+            groupId "org.matrix.android"
+            artifactId "${artifactId}"
+            version "1.4.4"
+            artifact "${artifactFilePath}"
+
+            // 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)
+                }
+            }
+        }
+    }
+    repositories {
+        maven {
+            url "https://gitlab.com/api/v4/projects/16/packages/maven"
+            credentials(HttpHeaderCredentials) {
+                name = "Private-Token"
+                value = "e3yxa-_Duy7xLabSa7_z"
+            }
+            authentication {
+                header(HttpHeaderAuthentication)
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/matrix-sdk-android/build.gradle b/matrix-sdk-android/build.gradle
index 6605acd2..3b10ff45 100644
--- a/matrix-sdk-android/build.gradle
+++ b/matrix-sdk-android/build.gradle
@@ -3,8 +3,6 @@ apply plugin: 'kotlin-android'
 apply plugin: 'kotlin-kapt'
 apply plugin: 'kotlin-parcelize'
 apply plugin: 'realm-android'
-// WARNING: always restore this line after importing code from Element Android (1/2)
-apply plugin: "com.vanniktech.maven.publish"
 
 buildscript {
     repositories {
-- 
GitLab