From aed9ff2a3ac60012d80de49d5beacefc02e8b338 Mon Sep 17 00:00:00 2001 From: Sabin Date: Thu, 17 Feb 2022 10:53:10 +1300 Subject: [PATCH 1/6] migration to maven central --- CHANGELOG.md | 10 ++- build.gradle | 9 ++- common.gradle | 12 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- publish-root.gradle | 38 ++++++++++ publishing.gradle | 89 +++++++++++++++++------- 6 files changed, 128 insertions(+), 32 deletions(-) create mode 100644 publish-root.gradle diff --git a/CHANGELOG.md b/CHANGELOG.md index 66b2f50..ca2d99b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,4 +10,12 @@ Version 2.0.0 *(05-09-2019)* ---------------------------- * Migrates to AndroidX - * Adds optional support for disabling swipe refresh layouts during swipes \ No newline at end of file + * Adds optional support for disabling swipe refresh layouts during swipes + +Version 2.0.1 *(17-02-2022)* +---------------------------- + + * Migration to maven central + *[Deprecation Details](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/) + + diff --git a/build.gradle b/build.gradle index b64fb84..84ee685 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,20 @@ +apply plugin: 'io.github.gradle-nexus.publish-plugin' +apply plugin: 'org.jetbrains.dokka' + buildscript { apply from: 'common.gradle' repositories { + maven { url "https://plugins.gradle.org/m2/" } google() jcenter() + mavenCentral() } dependencies { classpath "com.android.tools.build:gradle:$android_gradle_plugin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "digital.wup:android-maven-publish:$android_maven_version" + classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' + classpath 'org.jetbrains.dokka:dokka-gradle-plugin:1.6.10' } } @@ -22,3 +28,4 @@ allprojects { task clean(type: Delete) { delete rootProject.buildDir } +apply from: "${rootDir}/publish-root.gradle" \ No newline at end of file diff --git a/common.gradle b/common.gradle index ac20346..e11571a 100644 --- a/common.gradle +++ b/common.gradle @@ -1,12 +1,14 @@ -ext.version = "2.0.0" +ext.version = "2.0.1" ext.group = "nz.co.trademe.covert" ext.repo = "Covert" ext.org = "trademe" ext.scm = 'https://github.com/TradeMe/Covert.git' +ext.connection = 'scm:git:github.com/TradeMe/Covert.git' +ext.developerConnection = 'scm:git:ssh://github.com/TradeMe/Covert.git' +ext.url = 'https://github.com/TradeMe/Covert' ext.description = 'Covert is a small Android library allowing you to use Material Swipe Actions within a RecyclerView' -ext.compile_sdk = 29 -ext.min_sdk = 15 +ext.compile_sdk = 30 +ext.min_sdk = 18 ext.kotlin_version = '1.3.50' -ext.android_maven_version = '3.6.2' -ext.android_gradle_plugin_version = '3.5.0' \ No newline at end of file +ext.android_gradle_plugin_version = '4.0.1' \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db7e2b6..dfda8c1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip diff --git a/publish-root.gradle b/publish-root.gradle new file mode 100644 index 0000000..6532af8 --- /dev/null +++ b/publish-root.gradle @@ -0,0 +1,38 @@ + +// Create variables with empty default values +ext["signing.keyId"] = '' +ext["signing.password"] = '' +ext["signing.key"] = '' +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' + +File secretPropsFile = project.rootProject.file('local.properties') +if (secretPropsFile.exists()) { + // Read local.properties file first if it exists + Properties p = new Properties() + new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } + p.each { name, value -> ext[name] = value } +} else { + // Use system environment variables + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') + ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') + ext["signing.password"] = System.getenv('SIGNING_PASSWORD') + ext["signing.key"] = System.getenv('SIGNING_KEY') + ext["snapshot"] = System.getenv('SNAPSHOT') +} + +// Set up Sonatype repository +nexusPublishing { + repositories { + sonatype { + stagingProfileId = sonatypeStagingProfileId + username = ossrhUsername + password = ossrhPassword + nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) + snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) + } + } +} \ No newline at end of file diff --git a/publishing.gradle b/publishing.gradle index f7342d8..86ce5d1 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -1,39 +1,80 @@ -if (project.plugins.hasPlugin("com.android.library")) { - apply plugin: 'digital.wup.android-maven-publish' +apply plugin: 'maven-publish' +apply plugin: 'signing' +apply plugin: 'org.jetbrains.dokka' - project.afterEvaluate { - task sourcesJar(type: Jar) { - from android.sourceSets.main.java.srcDirs - } - } +task androidSourcesJar(type: Jar) { + archiveClassifier.set('sources') - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.source - } + // For Android libraries + from android.sourceSets.main.java.srcDirs + from android.sourceSets.main.kotlin.srcDirs + +} +artifacts { + archives androidSourcesJar +} + + +afterEvaluate { publishing { + publications { - aar(MavenPublication) { - from project.components.android - artifact project.androidSourcesJar + release(MavenPublication) { groupId project.ext.group - artifactId project.name + artifactId project.ext.repo version project.ext.version - } - } - repositories { - maven { - name 'Bintray' - url "https://api.bintray.com/maven/${project.org}/${project.repo}/${project.name}/;publish=1" + // Two artifacts, the `aar` (or `jar`) and the sources + if (project.plugins.findPlugin("com.android.library")) { + from components.release + } + + artifact androidSourcesJar + + // metadata + pom { + name = project.ext.repo + description = 'SDK' + url = project.ext.url + licenses { + license { + name = 'Covert License' + url = 'https://github.com/TradeMe/Covert/blob/master/LICENSE' + } + } + developers { + developer { + id = 'sabinmj' + name = 'Sabin' + email = 'sabin.mj@gmail.com' + } + // Add all other devs here... + } + + // Version control info - if you're using GitHub, follow the + // format as seen here + scm { + connection = project.ext.connection + developerConnection = project.ext.developerConnection + url = project.ext.url - credentials { - username BINTRAY_USERNAME - password BINTRAY_API_KEY + } } } } } +} +signing { + useInMemoryPgpKeys( + rootProject.ext["signing.keyId"], + rootProject.ext["signing.key"], + rootProject.ext["signing.password"], + ) + sign publishing.publications +} +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } \ No newline at end of file From 4b366373a6e2c9267f6a187ad0a29a2baf0fa36d Mon Sep 17 00:00:00 2001 From: Sabin Date: Thu, 17 Feb 2022 13:09:16 +1300 Subject: [PATCH 2/6] added github actions --- .github/workflows/publish.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..774cef3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +name: Publish + +on: + push: + branches: + - main + - 'releases/**' + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + + # Builds the release artifacts of the library + - name: Release build + run: ./gradlew :stream-chat-android-client:assembleRelease + + # Generates other artifacts (javadocJar is optional) + - name: Source jar and dokka + run: ./gradlew androidSourcesJar javadocJar + + # Runs upload, and then closes & releases the repository + - name: Publish to MavenCentral + run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} \ No newline at end of file From cf3092b912c7e0e8207845556e1d62244f7ce7c9 Mon Sep 17 00:00:00 2001 From: Sabin Date: Thu, 17 Feb 2022 16:09:51 +1300 Subject: [PATCH 3/6] lint fixes --- .github/workflows/publish.yml | 12 ++++++------ common.gradle | 2 +- publishing.gradle | 22 +++++++++++++++++----- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 774cef3..286f1a3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,15 +15,15 @@ jobs: uses: actions/checkout@v2 - name: Set up JDK 11 uses: actions/setup-java@v2 - with: - distribution: adopt - java-version: 11 + with: + distribution: adopt + java-version: 11 # Builds the release artifacts of the library - name: Release build - run: ./gradlew :stream-chat-android-client:assembleRelease + run: ./gradlew :covert:assembleRelease - # Generates other artifacts (javadocJar is optional) + # Generates other artifacts - name: Source jar and dokka run: ./gradlew androidSourcesJar javadocJar @@ -36,4 +36,4 @@ jobs: SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} - SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} \ No newline at end of file + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} diff --git a/common.gradle b/common.gradle index e11571a..8f1313c 100644 --- a/common.gradle +++ b/common.gradle @@ -1,6 +1,6 @@ ext.version = "2.0.1" ext.group = "nz.co.trademe.covert" -ext.repo = "Covert" +ext.repo = "covert" ext.org = "trademe" ext.scm = 'https://github.com/TradeMe/Covert.git' ext.connection = 'scm:git:github.com/TradeMe/Covert.git' diff --git a/publishing.gradle b/publishing.gradle index 86ce5d1..6bb3615 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -5,18 +5,28 @@ apply plugin: 'org.jetbrains.dokka' task androidSourcesJar(type: Jar) { archiveClassifier.set('sources') + if (project.plugins.findPlugin("com.android.library")) { + // For Android libraries + from android.sourceSets.main.java.srcDirs + from android.sourceSets.main.kotlin.srcDirs + } else { + from sourceSets.main.java.srcDirs + from sourceSets.main.kotlin.srcDirs + } - // For Android libraries - from android.sourceSets.main.java.srcDirs - from android.sourceSets.main.kotlin.srcDirs } +task javadocJar(type: Jar, dependsOn: dokkaJavadoc) { + archiveClassifier.set('javadoc') + from dokkaJavadoc.outputDirectory +} + artifacts { archives androidSourcesJar + archives javadocJar } - afterEvaluate { publishing { @@ -26,12 +36,14 @@ afterEvaluate { artifactId project.ext.repo version project.ext.version - // Two artifacts, the `aar` (or `jar`) and the sources if (project.plugins.findPlugin("com.android.library")) { from components.release + } else { + from components.java } artifact androidSourcesJar + artifact javadocJar // metadata pom { From 73988c4114bb90f9e52632b9770a6896bb37da3a Mon Sep 17 00:00:00 2001 From: Sabin Date: Mon, 28 Feb 2022 11:30:13 +1300 Subject: [PATCH 4/6] snapshot fixes --- .github/workflows/publish.yml | 1 + .github/workflows/snapshot.yml | 41 ++++++++++++++++++++++++++++++++++ covert/build.gradle | 7 +++--- publish-root.gradle | 9 ++++++++ publishing.gradle | 2 +- 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/snapshot.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 286f1a3..35d3939 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -37,3 +37,4 @@ jobs: SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} SIGNING_KEY: ${{ secrets.SIGNING_KEY }} SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + SNAPSHOT: false \ No newline at end of file diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml new file mode 100644 index 0000000..ef9b850 --- /dev/null +++ b/.github/workflows/snapshot.yml @@ -0,0 +1,41 @@ +name: Publish Snapshot builds + + +on: + push: + branches: + - development + - 'snapshot/**' + + + + +jobs: + publish: + name: Snapshot build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + - name: Release build + + run: ./gradlew :covert:assembleRelease + - name: Source jar and dokka + run: ./gradlew androidSourcesJar javadocJar + - name: Publish to MavenCentral + run: ./gradlew publishReleasePublicationToSonatypeRepository + + +env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + SNAPSHOT: true \ No newline at end of file diff --git a/covert/build.gradle b/covert/build.gradle index 3489aa2..22916b2 100644 --- a/covert/build.gradle +++ b/covert/build.gradle @@ -3,6 +3,10 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' +ext { + PUBLISH_VERSION = rootVersionName +} + apply from: '../common.gradle' apply from: '../publishing.gradle' @@ -17,9 +21,6 @@ android { } } -ext { - name = "Covert" -} dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) diff --git a/publish-root.gradle b/publish-root.gradle index 6532af8..7cbd261 100644 --- a/publish-root.gradle +++ b/publish-root.gradle @@ -23,11 +23,20 @@ if (secretPropsFile.exists()) { ext["signing.key"] = System.getenv('SIGNING_KEY') ext["snapshot"] = System.getenv('SNAPSHOT') } +if (Boolean.parseBoolean(snapshot)) { + ext["rootVersionName"] = project.ext.version + "-SNAPSHOT" +} else { + ext["rootVersionName"] = project.ext.version +} + // Set up Sonatype repository nexusPublishing { repositories { sonatype { + useStaging.set(provider { + !Boolean.parseBoolean(snapshot) + }) stagingProfileId = sonatypeStagingProfileId username = ossrhUsername password = ossrhPassword diff --git a/publishing.gradle b/publishing.gradle index 6bb3615..8661103 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -34,7 +34,7 @@ afterEvaluate { release(MavenPublication) { groupId project.ext.group artifactId project.ext.repo - version project.ext.version + version PUBLISH_VERSION if (project.plugins.findPlugin("com.android.library")) { from components.release From c4813372cce00c330e95c44b01a91806992f9086 Mon Sep 17 00:00:00 2001 From: Sabin Date: Fri, 11 Mar 2022 16:33:42 +1300 Subject: [PATCH 5/6] MP- 178 developer name change --- publishing.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/publishing.gradle b/publishing.gradle index 8661103..c49009d 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -59,8 +59,8 @@ afterEvaluate { developers { developer { id = 'sabinmj' - name = 'Sabin' - email = 'sabin.mj@gmail.com' + name = 'Sabin Mulakukodiyan' + email = 'sabin.mulakukodiyan@trademe.co.nz' } // Add all other devs here... } From 54450c1881779613475fe7cfd481e24a693d39f1 Mon Sep 17 00:00:00 2001 From: Sabin Date: Tue, 22 Mar 2022 09:22:56 +1300 Subject: [PATCH 6/6] MP- 178 credentials made optional --- publish-root.gradle | 1 + publishing.gradle | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/publish-root.gradle b/publish-root.gradle index 7cbd261..2c5fae8 100644 --- a/publish-root.gradle +++ b/publish-root.gradle @@ -6,6 +6,7 @@ ext["signing.key"] = '' ext["ossrhUsername"] = '' ext["ossrhPassword"] = '' ext["sonatypeStagingProfileId"] = '' +ext["snapshot"] = 'true' File secretPropsFile = project.rootProject.file('local.properties') if (secretPropsFile.exists()) { diff --git a/publishing.gradle b/publishing.gradle index c49009d..02ec1f5 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -79,12 +79,17 @@ afterEvaluate { } } signing { - useInMemoryPgpKeys( - rootProject.ext["signing.keyId"], - rootProject.ext["signing.key"], - rootProject.ext["signing.password"], - ) - sign publishing.publications + if (rootProject.ext["signing.keyId"] && rootProject.ext["signing.key"] && rootProject.ext["signing.password"]) { + useInMemoryPgpKeys( + rootProject.ext["signing.keyId"], + rootProject.ext["signing.key"], + rootProject.ext["signing.password"], + ) + sign publishing.publications + + } else { + sign configurations.archives + } } java { sourceCompatibility = JavaVersion.VERSION_1_8