Skip to content

Commit 84d58db

Browse files
committed
release: SDK 1.19.1
1 parent fffa2cb commit 84d58db

File tree

16 files changed

+9247
-86
lines changed

16 files changed

+9247
-86
lines changed

Sources/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ buildscript {
99
google()
1010
}
1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:7.1.2'
12+
classpath 'com.android.tools.build:gradle:7.2.1'
1313
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.21.1"
1414
// NOTE: Do not place your application dependencies here; they belong
1515
// in the individual module build.gradle files

Sources/gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ org.gradle.configureondemand=false
1919
android.useAndroidX=true
2020
android.enableJetifier=true
2121
gnsp.disableApplyOnlyOnRootProjectEnforcement=true
22+
kotlin.stdlib.default.dependency=false
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.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

Sources/sdk/build.gradle

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
3-
apply plugin: 'kotlin-android-extensions'
43

54
def SDK_VERSION = "SDK_VERSION"
65
def ENABLE_DEBUG_LOGGER = "ENABLE_DEBUG_LOGGER"
@@ -26,7 +25,7 @@ android {
2625
minSdkVersion 15
2726
targetSdkVersion 32
2827
versionCode 1
29-
versionName "1.19.0"
28+
versionName "1.19.1"
3029
buildConfigField "String", SDK_VERSION, "\"$versionName\""
3130
buildConfigField "Integer", API_LEVEL, '50'
3231
buildConfigField "Integer", MESSAGING_API_LEVEL, '12'
@@ -80,6 +79,13 @@ android {
8079
baseline file('lint-baseline.xml')
8180
lintConfig file('lint.xml')
8281
}
82+
83+
publishing {
84+
singleVariant("release") {
85+
withSourcesJar()
86+
withJavadocJar()
87+
}
88+
}
8389
}
8490

8591
// Prevent from having accidental kotlin in production code
@@ -91,6 +97,13 @@ afterEvaluate {
9197
}
9298
}
9399

100+
// Print the sdk version name
101+
task printVersion {
102+
doLast {
103+
println project.version
104+
}
105+
}
106+
94107
dependencies {
95108
compileOnly "com.google.android.gms:play-services-ads:$playServicesVersion"
96109
compileOnly "com.google.android.gms:play-services-gcm:$playServicesVersion"
@@ -147,7 +160,7 @@ dependencies {
147160
testImplementation "org.powermock:powermock-api-mockito2:2.0.7"
148161
testImplementation "org.powermock:powermock-classloading-xstream:2.0.7"
149162

150-
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
163+
testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
151164
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_couroutines_version"
152165
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_couroutines_version"
153166
}

Sources/sdk/maven-publish.gradle

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,50 +19,21 @@ if (signingFile.exists()) {
1919
}
2020
}
2121

22-
sourceSets {
23-
main {
24-
java.srcDirs += 'build/generated'
25-
}
26-
}
27-
28-
task androidJavadocs(type: Javadoc) {
29-
source = sourceSets.main.java.srcDirs
30-
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
31-
options.addStringOption('Xdoclint:none', '-quiet')
32-
android.libraryVariants.all { variant ->
33-
if (variant.name == 'release') {
34-
owner.classpath += variant.getCompileClasspath()
35-
}
36-
}
37-
exclude '**/gif/README'
38-
exclude '**/R.html', '**/R.*.html', '**/index.html'
39-
}
40-
41-
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
42-
archiveClassifier.set("javadoc")
43-
from androidJavadocs.destinationDir
44-
}
45-
46-
task androidSourcesJar(type: Jar) {
47-
archiveClassifier.set("sources")
48-
from sourceSets.main.java.srcDirs
49-
}
50-
5122
nexusStaging {
5223
packageGroup = mavenGroupId
5324
}
5425

5526
publishing {
5627
publications {
57-
batchsdk(MavenPublication) {
28+
release(MavenPublication) {
5829

5930
groupId mavenGroupId
6031
artifactId mavenArtifact
6132
version android.defaultConfig.versionName
6233

63-
artifact(project.rootProject.file("../public-sdk/Batch.aar"))
64-
artifact androidJavadocsJar
65-
artifact androidSourcesJar
34+
afterEvaluate {
35+
from components.release
36+
}
6637

6738
pom {
6839
name = "Batch.com Android SDK"
@@ -210,19 +181,6 @@ publishing {
210181
url = "https://batch.com"
211182
}
212183
}
213-
214-
pom.withXml {
215-
def dependenciesNode = asNode().appendNode('dependencies')
216-
217-
// Add dependencies manually as we have only one
218-
// See : https://discuss.gradle.org/t/maven-publish-doesnt-include-dependencies-in-the-project-pom-file/8544
219-
def dependencyNode = dependenciesNode.appendNode('dependency')
220-
dependencyNode.appendNode('groupId', 'androidx.core')
221-
dependencyNode.appendNode('artifactId', 'core')
222-
dependencyNode.appendNode('version', androidXLibraryVersion)
223-
dependencyNode.appendNode('scope', 'compile')
224-
dependencyNode.appendNode('type', 'aar')
225-
}
226184
}
227185
}
228186

@@ -246,7 +204,7 @@ publishing {
246204
}
247205

248206
signing {
249-
sign publishing.publications.batchsdk
207+
sign publishing.publications.release
250208
}
251209

252210
// Do not sign if we run the publishToMavenLocal task, useful for dev

Sources/sdk/metalava.gradle

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
* We can compare a previously generated signature file with the current API using the metalavaCompareSignature task.
1111
*/
1212

13+
configurations {
14+
metalavaRuntime
15+
}
16+
17+
dependencies {
18+
metalavaRuntime 'com.android.tools.metalava:metalava:1.0.0-alpha04'
19+
}
20+
1321
/**
1422
* Recursively list all packages from a directory
1523
* The package must contains at least one .java file to be included
@@ -39,7 +47,7 @@ void getPackagesInDirectory(File rootDirectory, File directory, Set<String> pack
3947
*/
4048
List<String> getBaseMetalavaArgs() {
4149
def args = [
42-
'-cp', project.rootProject.file('../prebuilt/*'),
50+
'-cp', configurations.metalavaRuntime.asPath,
4351
'com.android.tools.metalava.Driver',
4452
'--format=v2',
4553
]
@@ -100,17 +108,24 @@ task metalavaGenerateSignature {
100108
addBaseline(signatureArgs, project.file('metalava-baseline.txt'))
101109
signatureArgs.addAll([
102110
'--source-path', android.sourceSets.main.java.srcDirs.toArray().join(':'),
103-
'--api', project.rootProject.file('../metalava-api/' + android.defaultConfig.versionName + '/api.txt')
111+
'--api', project.rootProject.file('../metalava-api/api-latest.txt')
104112
])
105113
exec {
106114
executable = 'java'
107115
args = signatureArgs
108116
}
117+
}
118+
}
109119

120+
// Generate a release metalava signature
121+
// This builds api-latest and copies it to a versioned release
122+
task("metalavaGenerateTaggedSignature", dependsOn: ["metalavaGenerateSignature"]) {
123+
doFirst {
110124
copy {
111-
from project.rootProject.file('../metalava-api/' + android.defaultConfig.versionName + '/api.txt')
112-
into project.rootProject.file('../metalava-api')
113-
rename 'api.txt', 'api-latest.txt'
125+
from project.rootProject.file('../metalava-api/api-latest.txt')
126+
into project.rootProject.file('../metalava-api/' + android.defaultConfig.versionName + '/')
127+
128+
rename 'api-latest.txt', 'api.txt'
114129
}
115130
}
116131
}

Sources/sdk/src/main/java/com/batch/android/BatchEventDispatcher.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ public interface BatchEventDispatcher {
1313
/**
1414
* Get the name of the dispatcher
1515
* This information is only used for analytics
16+
*
17+
* /!\ `default` method can lead to an AbstractMethodError if java 8 language features are not available (api < 24).
18+
* Ensure catching the exception when using this method or use reflection check.
19+
*
1620
* @return the name of the dispatcher
1721
*/
1822
@Nullable
@@ -23,6 +27,10 @@ default String getName() {
2327
/**
2428
* Get the version of the dispatcher
2529
* This information is only used for analytics
30+
*
31+
* /!\ `default` method can lead to an AbstractMethodError if java 8 language features are not available (api < 24).
32+
* Ensure catching the exception when using this method or use reflection check.
33+
*
2634
* @return the version of the dispatcher
2735
*/
2836
default int getVersion() {

Sources/sdk/src/main/java/com/batch/android/BatchPushMessageReceiver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ protected boolean presentNotification(@NonNull Context context, @NonNull Intent
9292
try {
9393
startPresentationService(context, intent);
9494
return true;
95-
} catch (IllegalStateException e) {
96-
// This exception can happen on Android O, fallback on scheduling a Job.
95+
} catch (IllegalStateException | SecurityException e) {
96+
// IllegalStateException can happen on Android O, fallback on scheduling a Job.
9797
// On earlier Android versions, it should not happen.
98+
// The SecurityException happens on some OEMs, like Wiko, for an unknown reason.
9899
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
99100
Logger.internal(TAG, "Failed to start service, scheduling Job");
100101
return scheduleJob(context, intent);

Sources/sdk/src/main/java/com/batch/android/eventdispatcher/DispatcherSerializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static JSONObject serialize(@NonNull Set<BatchEventDispatcher> dispatcher
5050
? dispatcher.getName()
5151
: CUSTOM_DISPATCHER_NAME;
5252
json.put(name, dispatcher.getVersion());
53-
} catch (JSONException ignored) {}
53+
} catch (JSONException | AbstractMethodError ignored) {}
5454
}
5555
return json;
5656
}

Sources/sdk/src/main/java/com/batch/android/messaging/fragment/UniversalTemplateFragment.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import java.io.IOException;
4141
import java.util.Locale;
4242
import java.util.Map;
43-
import org.jetbrains.annotations.NotNull;
4443

4544
/**
4645
* Universal messaging template fragment class. Extends DialogFragment so it can be displayed in its own window easily.
@@ -122,7 +121,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
122121
@Nullable
123122
@Override
124123
public View onCreateView(
125-
@NotNull LayoutInflater inflater,
124+
@NonNull LayoutInflater inflater,
126125
@Nullable ViewGroup container,
127126
@Nullable Bundle savedInstanceState
128127
) {

0 commit comments

Comments
 (0)