From ca8fe193a110af02f027075265121229c0f2442a Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Fri, 13 Jun 2025 20:01:40 -0400 Subject: [PATCH 1/2] share buildscript block between gradle scripts We will need these as variables so they can be shared with future changes we are going to make to maven-push.gradle. "apply from:" doesn't have an option to share the classpath. --- OneSignalSDK/build.gradle | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/OneSignalSDK/build.gradle b/OneSignalSDK/build.gradle index dd2638f8a8..977c232ede 100644 --- a/OneSignalSDK/build.gradle +++ b/OneSignalSDK/build.gradle @@ -19,21 +19,29 @@ buildscript { ktlintVersion = '1.0.1' // DO NOT upgrade for tests, using an old version so it matches AOSP tdunningJsonForTest = '1.0' - } - repositories { - google() - mavenCentral() - gradlePluginPortal() - // Huawei maven - maven { url 'https://developer.huawei.com/repo/' } + sharedRepos = { + google() + mavenCentral() + gradlePluginPortal() + // Huawei maven + maven { url 'https://developer.huawei.com/repo/' } + } + sharedDeps = [ + "com.android.tools.build:gradle:$androidGradlePluginVersion", + "com.google.gms:google-services:$googleServicesGradlePluginVersion", + "com.huawei.agconnect:agcp:$huaweiAgconnectVersion", + "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion", + "org.jlleitschuh.gradle:ktlint-gradle:$ktlintPluginVersion", + "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin:0.32.0" + ] } - dependencies { - classpath "com.android.tools.build:gradle:$androidGradlePluginVersion" - classpath "com.google.gms:google-services:$googleServicesGradlePluginVersion" - classpath "com.huawei.agconnect:agcp:$huaweiAgconnectVersion" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - classpath "org.jlleitschuh.gradle:ktlint-gradle:$ktlintPluginVersion" + + buildscript { + repositories sharedRepos + dependencies { + classpath sharedDeps + } } } From 4ae6907bae530f57d30480d7b73826d1eba6b6b5 Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Fri, 13 Jun 2025 20:13:38 -0400 Subject: [PATCH 2/2] Switch publishing to the Central Portal OSSRH is shutting down soon so we need to migrate to the Central Portal for publishing. * There are no changes to those consuming this SDK, only for mainliners to publish. Add the "plugin com.vanniktech.maven.publish" plugin to publish to the Central Portal. To publish the following command must be used now: ./gradlew publishToMavenCentral --no-configuration-cache \ -PmavenCentralUsername=USER_TOKEN_USERNAME_HERE \ -PmavenCentralPassword=USER_TOKEN_PASSWORD_HERE \ -Psigning.keyId=ID_HERE \ -Psigning.password=PASSWORD_HERE \ -Psigning.secretKeyRingFile=/FULL/PATH/TO/GPG_FILE_HERE Can switch to publishAndReleaseToMavenCentral once we do a release manually and test end-to-end. --- OneSignalSDK/onesignal/build.gradle | 1 + OneSignalSDK/onesignal/core/build.gradle | 1 + .../onesignal/in-app-messages/build.gradle | 1 + OneSignalSDK/onesignal/location/build.gradle | 1 + OneSignalSDK/onesignal/maven-push.gradle | 130 +++++------------- .../onesignal/notifications/build.gradle | 1 + 6 files changed, 38 insertions(+), 97 deletions(-) diff --git a/OneSignalSDK/onesignal/build.gradle b/OneSignalSDK/onesignal/build.gradle index 952c3dc5e9..1bae953843 100644 --- a/OneSignalSDK/onesignal/build.gradle +++ b/OneSignalSDK/onesignal/build.gradle @@ -4,6 +4,7 @@ plugins { // however consumers look for an .aar file, which this causes it // to be created. id 'kotlin-android' + id 'com.vanniktech.maven.publish' } android { diff --git a/OneSignalSDK/onesignal/core/build.gradle b/OneSignalSDK/onesignal/core/build.gradle index 6dd200a429..d91d96ae88 100644 --- a/OneSignalSDK/onesignal/core/build.gradle +++ b/OneSignalSDK/onesignal/core/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'kotlin-android' id 'org.jlleitschuh.gradle.ktlint' + id 'com.vanniktech.maven.publish' } android { diff --git a/OneSignalSDK/onesignal/in-app-messages/build.gradle b/OneSignalSDK/onesignal/in-app-messages/build.gradle index b2543d1297..141e2f0260 100644 --- a/OneSignalSDK/onesignal/in-app-messages/build.gradle +++ b/OneSignalSDK/onesignal/in-app-messages/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'kotlin-android' id 'org.jlleitschuh.gradle.ktlint' + id 'com.vanniktech.maven.publish' } android { diff --git a/OneSignalSDK/onesignal/location/build.gradle b/OneSignalSDK/onesignal/location/build.gradle index 22b8c754cd..f0ad49dea3 100644 --- a/OneSignalSDK/onesignal/location/build.gradle +++ b/OneSignalSDK/onesignal/location/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'kotlin-android' id 'org.jlleitschuh.gradle.ktlint' + id 'com.vanniktech.maven.publish' } android { diff --git a/OneSignalSDK/onesignal/maven-push.gradle b/OneSignalSDK/onesignal/maven-push.gradle index 299c9fca8a..234d9419bf 100644 --- a/OneSignalSDK/onesignal/maven-push.gradle +++ b/OneSignalSDK/onesignal/maven-push.gradle @@ -1,108 +1,44 @@ -/** - * Modified MIT License - * - * Copyright 2021 OneSignal - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * 1. The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * 2. All copies of substantial portions of the Software may only be used in connection - * with services provided by OneSignal. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ +buildscript { + repositories sharedRepos + dependencies { + classpath sharedDeps + } +} -apply plugin: 'maven-publish' -apply plugin: 'signing' +import com.vanniktech.maven.publish.AndroidSingleVariantLibrary +import com.vanniktech.maven.publish.SonatypeHost -class Global { - static def POM_PACKAGING = 'aar' +mavenPublishing { + configure(new AndroidSingleVariantLibrary("release", true, true)) + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) - static def POM_URL = 'https://github.com/onesignal/onesignal-android-sdk' - static def POM_SCM_URL = 'https://github.com/onesignal/onesignal-android-sdk' - static def POM_SCM_CONNECTION = 'scm:git:https://github.com/onesignal/onesignal-android-sdk' - static def POM_SCM_DEV_CONNECTION = 'scm:git:https://github.com/onesignal/onesignal-android-sdk' - static def POM_LICENCE_NAME = 'MIT License' - static def POM_LICENCE_URL = 'https://raw.githubusercontent.com/onesignal/onesignal-android-sdk/master/LICENSE' - static def POM_LICENCE_DIST = 'repo' - static def POM_DEVELOPER_ID = 'OneSignal' - static def POM_DEVELOPER_NAME = 'Josh Kasten' - static def SNAPSHOT_REPOSITORY_URL = 'https://oss.sonatype.org/content/repositories/snapshots' - static def RELEASE_REPOSITORY_URL = 'https://oss.sonatype.org/service/local/staging/deploy/maven2' -} + signAllPublications() -def getRepositoryUsername() { - return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" -} + coordinates(project.group, project.name, project.version) -def getRepositoryPassword() { - return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" -} - -afterEvaluate { - publishing { - repositories { - maven { - url = Global.RELEASE_REPOSITORY_URL - credentials { - username = getRepositoryUsername() - password = getRepositoryPassword() - } + pom { + name = "OneSignal Android SDK" + description = "OneSignal is a free email, sms, push notification, and in-app message service for mobile apps. This plugin makes it easy to integrate your native Android or Amazon app with OneSignal." + inceptionYear = "2015" + url = "https://github.com/onesignal/onesignal-android-sdk/" + licenses { + license { + name = "Modified MIT License" + url = "https://raw.githubusercontent.com/onesignal/onesignal-android-sdk/main/LICENSE" + distribution = "repo" } } - - publications { - release(MavenPublication) { - afterEvaluate { - from components.findByName('release') - } - - pom { - name = projectName - description = projectDescription - packaging = Global.POM_PACKAGING - url = Global.POM_URL - - scm { - url = Global.POM_SCM_URL - connection = Global.POM_SCM_CONNECTION - developerConnection = Global.POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name = Global.POM_LICENCE_NAME - url = Global.POM_LICENCE_URL - distribution = Global.POM_LICENCE_DIST - } - } - - developers { - developer { - id = Global.POM_DEVELOPER_ID - name = Global.POM_DEVELOPER_NAME - } - } - } + developers { + developer { + id = "OneSignal" + name = "OneSignal" + url = "https://github.com/OneSignal/" } } - } - - signing { - required { true } - sign publishing.publications.release + scm { + url = "https://github.com/onesignal/onesignal-android-sdk" + connection = "scm:git:git://github.com/onesignal/onesignal-android-sdk.git" + developerConnection = "scm:git:ssh://git@github.com/onesignal/onesignal-android-sdk.git" + } } } diff --git a/OneSignalSDK/onesignal/notifications/build.gradle b/OneSignalSDK/onesignal/notifications/build.gradle index 8ad12216b7..526d68723d 100644 --- a/OneSignalSDK/onesignal/notifications/build.gradle +++ b/OneSignalSDK/onesignal/notifications/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.library' id 'kotlin-android' id 'org.jlleitschuh.gradle.ktlint' + id 'com.vanniktech.maven.publish' } android {