Skip to content

Commit 53e7c61

Browse files
authored
Merge pull request #2331 from OneSignal/main-gradle8-and-central-portal
[Main] Cherry picks from 5.2.x - Migrate to Gradle/AGP 8 & Changes to publish to the Central Portal.
2 parents f866e92 + b67fb23 commit 53e7c61

File tree

15 files changed

+81
-128
lines changed

15 files changed

+81
-128
lines changed

Examples/OneSignalDemo/app/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
}
44

55
android {
6+
namespace 'com.onesignal.sdktest'
67
compileSdkVersion 34
78
defaultConfig {
89
minSdkVersion 21
@@ -61,10 +62,11 @@ android {
6162
}
6263

6364
task flavorSelection() {
64-
if (getGradle().getStartParameter().getTaskRequests().toString().contains("Gms")) {
65+
def tasksList = gradle.startParameter.taskRequests.toString()
66+
if (tasksList.contains('Gms')) {
6567
apply plugin: 'com.google.gms.google-services'
6668
googleServices { disableVersionCheck = true }
67-
} else {
69+
} else if (tasksList.contains('Huawei')) {
6870
apply plugin: 'com.huawei.agconnect'
6971
}
7072
}

Examples/OneSignalDemo/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:tools="http://schemas.android.com/tools"
4-
xmlns:amazon="http://schemas.amazon.com/apk/res/android"
5-
package="com.onesignal.sdktest">
4+
xmlns:amazon="http://schemas.amazon.com/apk/res/android">
65

76
<uses-permission android:name="com.android.vending.BILLING" />
87

Examples/OneSignalDemo/app/src/main/java/com/onesignal/sdktest/application/MainApplication.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.onesignal.notifications.IDisplayableNotification;
2121
import com.onesignal.notifications.INotificationLifecycleListener;
2222
import com.onesignal.notifications.INotificationWillDisplayEvent;
23-
import com.onesignal.sdktest.BuildConfig;
2423
import com.onesignal.sdktest.R;
2524
import com.onesignal.sdktest.constant.Tag;
2625
import com.onesignal.sdktest.constant.Text;
@@ -38,9 +37,8 @@ public class MainApplication extends MultiDexApplication {
3837
private static final int SLEEP_TIME_TO_MIMIC_ASYNC_OPERATION = 2000;
3938

4039
public MainApplication() {
41-
// run strict mode default in debug mode to surface any potential issues easier
42-
if(BuildConfig.DEBUG)
43-
StrictMode.enableDefaults();
40+
// run strict mode to surface any potential issues easier
41+
StrictMode.enableDefaults();
4442
}
4543

4644
@SuppressLint("NewApi")

Examples/OneSignalDemo/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ buildscript {
1212
maven { url 'https://developer.huawei.com/repo/' }
1313
}
1414
dependencies {
15-
classpath 'com.android.tools.build:gradle:7.2.2'
15+
classpath 'com.android.tools.build:gradle:8.8.2'
1616
classpath 'com.google.gms:google-services:4.3.10'
17-
classpath 'com.huawei.agconnect:agcp:1.6.2.300'
17+
classpath 'com.huawei.agconnect:agcp:1.9.1.304'
1818

1919
// TODO: Do not place your application dependencies here; they belong
2020
// in the individual module build.gradle files
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

OneSignalSDK/build.gradle

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ buildscript {
88
targetSdkVersion: 34,
99
minSdkVersion: 21
1010
]
11-
androidGradlePluginVersion = '7.2.0'
11+
androidGradlePluginVersion = '8.8.2'
1212
googleServicesGradlePluginVersion = '4.3.10'
13-
huaweiAgconnectVersion = '1.6.2.300'
13+
huaweiAgconnectVersion = '1.9.1.304'
1414
huaweiHMSPushVersion = '6.3.0.304'
1515
huaweiHMSLocationVersion = '4.0.0.300'
1616
kotlinVersion = '1.7.10'
@@ -19,21 +19,29 @@ buildscript {
1919
ktlintVersion = '1.0.1'
2020
// DO NOT upgrade for tests, using an old version so it matches AOSP
2121
tdunningJsonForTest = '1.0'
22-
}
2322

24-
repositories {
25-
google()
26-
mavenCentral()
27-
gradlePluginPortal()
28-
// Huawei maven
29-
maven { url 'https://developer.huawei.com/repo/' }
23+
sharedRepos = {
24+
google()
25+
mavenCentral()
26+
gradlePluginPortal()
27+
// Huawei maven
28+
maven { url 'https://developer.huawei.com/repo/' }
29+
}
30+
sharedDeps = [
31+
"com.android.tools.build:gradle:$androidGradlePluginVersion",
32+
"com.google.gms:google-services:$googleServicesGradlePluginVersion",
33+
"com.huawei.agconnect:agcp:$huaweiAgconnectVersion",
34+
"org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion",
35+
"org.jlleitschuh.gradle:ktlint-gradle:$ktlintPluginVersion",
36+
"com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin:0.32.0"
37+
]
3038
}
31-
dependencies {
32-
classpath "com.android.tools.build:gradle:$androidGradlePluginVersion"
33-
classpath "com.google.gms:google-services:$googleServicesGradlePluginVersion"
34-
classpath "com.huawei.agconnect:agcp:$huaweiAgconnectVersion"
35-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
36-
classpath "org.jlleitschuh.gradle:ktlint-gradle:$ktlintPluginVersion"
39+
40+
buildscript {
41+
repositories sharedRepos
42+
dependencies {
43+
classpath sharedDeps
44+
}
3745
}
3846
}
3947

OneSignalSDK/gradle.properties

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
# Remove when creating an .aar build.
2424
#android.enableAapt2=false
2525

26-
android.databinding.incremental = false
27-
kapt.incremental.apt = false
28-
android.testConfig.useRelativePath = false
26+
org.gradle.jvmargs=-Xmx1536m
2927

3028
# Enables D8 for all modules.
3129
android.enableD8 = true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

OneSignalSDK/onesignal/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
plugins {
22
id 'com.android.library'
3+
// There isn't Kotlin or Java code in this top-level project,
4+
// however consumers look for an .aar file, which this causes it
5+
// to be created.
6+
id 'kotlin-android'
7+
id 'com.vanniktech.maven.publish'
38
}
49

510
android {
@@ -25,6 +30,8 @@ android {
2530
targetCompatibility JavaVersion.VERSION_1_8
2631
}
2732
namespace 'com.onesignal'
33+
34+
kotlinOptions.freeCompilerArgs += ['-module-name', namespace]
2835
}
2936

3037
ext {

OneSignalSDK/onesignal/core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'com.android.library'
33
id 'kotlin-android'
44
id 'org.jlleitschuh.gradle.ktlint'
5+
id 'com.vanniktech.maven.publish'
56
}
67

78
android {

OneSignalSDK/onesignal/in-app-messages/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'com.android.library'
33
id 'kotlin-android'
44
id 'org.jlleitschuh.gradle.ktlint'
5+
id 'com.vanniktech.maven.publish'
56
}
67

78
android {

OneSignalSDK/onesignal/location/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'com.android.library'
33
id 'kotlin-android'
44
id 'org.jlleitschuh.gradle.ktlint'
5+
id 'com.vanniktech.maven.publish'
56
}
67

78
android {
Lines changed: 33 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,44 @@
1-
/**
2-
* Modified MIT License
3-
*
4-
* Copyright 2021 OneSignal
5-
*
6-
* Permission is hereby granted, free of charge, to any person obtaining a copy
7-
* of this software and associated documentation files (the "Software"), to deal
8-
* in the Software without restriction, including without limitation the rights
9-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10-
* copies of the Software, and to permit persons to whom the Software is
11-
* furnished to do so, subject to the following conditions:
12-
*
13-
* 1. The above copyright notice and this permission notice shall be included in
14-
* all copies or substantial portions of the Software.
15-
*
16-
* 2. All copies of substantial portions of the Software may only be used in connection
17-
* with services provided by OneSignal.
18-
*
19-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25-
* THE SOFTWARE.
26-
*/
1+
buildscript {
2+
repositories sharedRepos
3+
dependencies {
4+
classpath sharedDeps
5+
}
6+
}
277

28-
apply plugin: 'maven-publish'
29-
apply plugin: 'signing'
8+
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
9+
import com.vanniktech.maven.publish.SonatypeHost
3010

31-
class Global {
32-
static def POM_PACKAGING = 'aar'
11+
mavenPublishing {
12+
configure(new AndroidSingleVariantLibrary("release", true, true))
13+
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
3314

34-
static def POM_URL = 'https://github.com/onesignal/onesignal-android-sdk'
35-
static def POM_SCM_URL = 'https://github.com/onesignal/onesignal-android-sdk'
36-
static def POM_SCM_CONNECTION = 'scm:git:https://github.com/onesignal/onesignal-android-sdk'
37-
static def POM_SCM_DEV_CONNECTION = 'scm:git:https://github.com/onesignal/onesignal-android-sdk'
38-
static def POM_LICENCE_NAME = 'MIT License'
39-
static def POM_LICENCE_URL = 'https://raw.githubusercontent.com/onesignal/onesignal-android-sdk/master/LICENSE'
40-
static def POM_LICENCE_DIST = 'repo'
41-
static def POM_DEVELOPER_ID = 'OneSignal'
42-
static def POM_DEVELOPER_NAME = 'Josh Kasten'
43-
static def SNAPSHOT_REPOSITORY_URL = 'https://oss.sonatype.org/content/repositories/snapshots'
44-
static def RELEASE_REPOSITORY_URL = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
45-
}
15+
signAllPublications()
4616

47-
def getRepositoryUsername() {
48-
return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : ""
49-
}
17+
coordinates(project.group, project.name, project.version)
5018

51-
def getRepositoryPassword() {
52-
return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : ""
53-
}
54-
55-
afterEvaluate {
56-
publishing {
57-
repositories {
58-
maven {
59-
url = Global.RELEASE_REPOSITORY_URL
60-
credentials {
61-
username = getRepositoryUsername()
62-
password = getRepositoryPassword()
63-
}
19+
pom {
20+
name = "OneSignal Android SDK"
21+
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."
22+
inceptionYear = "2015"
23+
url = "https://github.com/onesignal/onesignal-android-sdk/"
24+
licenses {
25+
license {
26+
name = "Modified MIT License"
27+
url = "https://raw.githubusercontent.com/onesignal/onesignal-android-sdk/main/LICENSE"
28+
distribution = "repo"
6429
}
6530
}
66-
67-
publications {
68-
release(MavenPublication) {
69-
from components.release
70-
71-
pom {
72-
name = projectName
73-
description = projectDescription
74-
packaging = Global.POM_PACKAGING
75-
url = Global.POM_URL
76-
77-
scm {
78-
url = Global.POM_SCM_URL
79-
connection = Global.POM_SCM_CONNECTION
80-
developerConnection = Global.POM_SCM_DEV_CONNECTION
81-
}
82-
83-
licenses {
84-
license {
85-
name = Global.POM_LICENCE_NAME
86-
url = Global.POM_LICENCE_URL
87-
distribution = Global.POM_LICENCE_DIST
88-
}
89-
}
90-
91-
developers {
92-
developer {
93-
id = Global.POM_DEVELOPER_ID
94-
name = Global.POM_DEVELOPER_NAME
95-
}
96-
}
97-
}
31+
developers {
32+
developer {
33+
id = "OneSignal"
34+
name = "OneSignal"
35+
url = "https://github.com/OneSignal/"
9836
}
9937
}
100-
}
101-
102-
signing {
103-
required { true }
104-
sign publishing.publications.release
38+
scm {
39+
url = "https://github.com/onesignal/onesignal-android-sdk"
40+
connection = "scm:git:git://github.com/onesignal/onesignal-android-sdk.git"
41+
developerConnection = "scm:git:ssh://git@github.com/onesignal/onesignal-android-sdk.git"
42+
}
10543
}
10644
}

OneSignalSDK/onesignal/notifications/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'com.android.library'
33
id 'kotlin-android'
44
id 'org.jlleitschuh.gradle.ktlint'
5+
id 'com.vanniktech.maven.publish'
56
}
67

78
android {

OneSignalSDK/onesignal/notifications/src/main/java/com/onesignal/notifications/internal/display/impl/NotificationDisplayBuilder.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import android.net.Uri
1212
import android.os.Build
1313
import androidx.core.app.NotificationCompat
1414
import com.onesignal.common.AndroidUtils
15-
import com.onesignal.core.R
1615
import com.onesignal.core.internal.application.IApplicationService
1716
import com.onesignal.debug.internal.logging.Logging
1817
import com.onesignal.notifications.internal.bundle.impl.NotificationBundleProcessor
@@ -231,9 +230,9 @@ internal class NotificationDisplayBuilder(
231230
if (bitmap == null) return null
232231
try {
233232
val systemLargeIconHeight =
234-
contextResources!!.getDimension(R.dimen.notification_large_icon_height).toInt()
233+
contextResources!!.getDimension(android.R.dimen.notification_large_icon_height).toInt()
235234
val systemLargeIconWidth =
236-
contextResources!!.getDimension(R.dimen.notification_large_icon_width).toInt()
235+
contextResources!!.getDimension(android.R.dimen.notification_large_icon_width).toInt()
237236
val bitmapHeight = bitmap.height
238237
val bitmapWidth = bitmap.width
239238
if (bitmapWidth > systemLargeIconWidth || bitmapHeight > systemLargeIconHeight) {

0 commit comments

Comments
 (0)