From 23380ca331bc5c3af22d93ee3b4aa400d92b43c9 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 6 Jan 2022 10:04:40 +0100 Subject: [PATCH] Release the library on MavenCentral Delete stuff added for Jitpack --- README.md | 8 ++++++++ android/README.rst | 16 ++++++---------- android/build.gradle | 10 +++++++++- android/gradle.properties | 24 ++++++++++++++++++++++- android/jitpack.yml | 3 --- android/olm-sdk/build.gradle | 37 +++--------------------------------- 6 files changed, 49 insertions(+), 49 deletions(-) delete mode 100644 android/jitpack.yml diff --git a/README.md b/README.md index 003f249..d1d6b72 100644 --- a/README.md +++ b/README.md @@ -167,6 +167,14 @@ Python and JavaScript packages are published to the registry at documentation contains instructions on how to set up twine (Python) and npm (JavaScript) to upload to the registry. +To publish the Android library to MavenCentral (you will need some secrets), in the /android folder: + - Run the command `./gradlew clean publish --no-daemon --no-parallel --stacktrace`. + - Connect to https://s01.oss.sonatype.org + - Click on Staging Repositories and check the the files have been uploaded + - Click on close + - Wait (check Activity tab until step "Repository closed" is displayed) + - Click on release. The staging repository will disappear + - Check that the release is available in https://repo1.maven.org/maven2/org/matrix/android/olm/ (it can take a few minutes) ## Design diff --git a/android/README.rst b/android/README.rst index c52a2ca..5d58f81 100644 --- a/android/README.rst +++ b/android/README.rst @@ -5,20 +5,16 @@ OlmLibSdk exposes an android wrapper to libolm. Installation ------------ -Create a libs directory in your project directory -Copy the olm-sdk.aar into it. -In your build.gradle file, add in the android section:: +Android Olm library is released on MavenCentral. - repositories { - flatDir { - dir 'libs' - } - } +Add this dependency to your project: -Add in the dependencies category:: +```groovy +implementation "org.matrix.android:olm:3.2.8" +``` - compile(name: 'olm-sdk', ext: 'aar') +Latest version: ![Latest version](https://img.shields.io/maven-central/v/org.matrix.android/olm) Development ----------- diff --git a/android/build.gradle b/android/build.gradle index 80e64bf..fd2647e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -9,7 +9,7 @@ buildscript { // Release notes of Android Gradle Plugin (AGP): // https://developer.android.com/studio/releases/gradle-plugin classpath 'com.android.tools.build:gradle:7.0.4' - + classpath 'com.vanniktech:gradle-maven-publish-plugin:0.17.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } @@ -20,6 +20,14 @@ allprojects { mavenCentral() google() } + + 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/android/gradle.properties b/android/gradle.properties index 9974766..c498e7f 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -22,6 +22,28 @@ android.useAndroidX=true org.gradle.configureondemand=false +# Maven publication +# Ref: https://github.com/vanniktech/gradle-maven-publish-plugin GROUP=org.matrix.android -ARTIFACT_ID=olm +POM_ARTIFACT_ID=olm VERSION_NAME=3.2.8 + +POM_PACKAGING=aar + +POM_NAME=Olm Android wrapper +POM_DESCRIPTION=An Android wrapper to libolm. +POM_INCEPTION_YEAR=2021 +POM_URL=https://gitlab.matrix.org/matrix-org/olm + +POM_LICENSE_NAME=The Apache Software License, Version 2.0 +POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt +POM_LICENCE_DIST=repo + +POM_SCM_URL=https://gitlab.matrix.org/matrix-org/olm +POM_SCM_CONNECTION=scm:git:git://gitlab.matrix.org/matrix-org/olm.git +POM_SCM_DEV_CONNECTION=scm:git:ssh://git@gitlab.matrix.org/matrix-org/olm.git + +POM_DEVELOPER_ID=matrixdev +POM_DEVELOPER_NAME=matrixdev +POM_DEVELOPER_URL=https://gitlab.matrix.org/matrix-org +POM_DEVELOPER_EMAIL=android@element.io diff --git a/android/jitpack.yml b/android/jitpack.yml deleted file mode 100644 index 17321ad..0000000 --- a/android/jitpack.yml +++ /dev/null @@ -1,3 +0,0 @@ -install: - - ./gradlew :olm-sdk:build :olm-sdk:publishToMavenLocal -x :olm-sdk:test - - find . -name "*.aar" \ No newline at end of file diff --git a/android/olm-sdk/build.gradle b/android/olm-sdk/build.gradle index 8a1d5fc..2748b82 100644 --- a/android/olm-sdk/build.gradle +++ b/android/olm-sdk/build.gradle @@ -1,8 +1,7 @@ import org.apache.tools.ant.taskdefs.condition.Os apply plugin: 'com.android.library' -apply plugin: 'maven-publish' -apply plugin: 'signing' +apply plugin: "com.vanniktech.maven.publish" android { compileSdk 31 @@ -12,6 +11,8 @@ android { targetSdk 31 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + buildConfigField "String", "OLM_VERSION", "\"${project.getProperties().getOrDefault("VERSION_NAME", "0.0.0")}\"" + // The following argument makes the Android Test Orchestrator run its // "pm clear" command after each test invocation. This command ensures // that the app's state is completely cleared between tests. @@ -158,35 +159,3 @@ dependencies { androidTestImplementation 'androidx.test:rules:1.4.0' androidTestImplementation 'androidx.test.ext:junit:1.1.3' } - -project.afterEvaluate { - publishing { - publications { - release(MavenPublication) { - from components.release - artifact androidJavadocsJar - artifact androidSourcesJar - groupId = project.getProperties().getOrDefault("GROUP", "org.matrix.android") - artifactId = project.getProperties().getOrDefault("ARTIFACT_ID", "olm") - version = project.getProperties().getOrDefault("VERSION_NAME", "0.0.0") - } - } - repositories { - maven { - url "https://gitlab.matrix.org/api/v4/projects/27/packages/maven" - credentials(HttpHeaderCredentials) { - name = System.getenv("REPO_TOKEN_TYPE") - value = System.getenv("REPO_TOKEN") - } - authentication { - header(HttpHeaderAuthentication) - } - } - } - } - - signing { - useGpgCmd() - sign publishing.publications.release - } -}