Skip to content

Commit

Permalink
upgrade: update AGP, Gradle, MParticle Android SDK (#14)
Browse files Browse the repository at this point in the history
- update android-core to 5.38.2
- update AGP to 7.1.2
- updage Gradle to 7.3.2
- update targetSdk, compileSdk to 31
- fix compilation errors
- migrade build files to kts
- and Android unit test CI workflow
  • Loading branch information
willpassidomo committed May 6, 2022
1 parent 60368be commit 9365d33
Show file tree
Hide file tree
Showing 17 changed files with 299 additions and 118 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/cordova-CI.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

name: "Build and Test"
on: [push, pull_request]
jobs:
js-test:
name: "JS Tests"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./plugin
strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 15.x]
steps:
- name: "Checkout Branch"
uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: "NPM Build"
run: npm ci; npm run build --if-present
- name: "NPM Test"
run: npm test
android-test:
name: "Android Unit Tests"
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./plugin
steps:
- name: "Checkout Branch"
uses: actions/checkout@v2
- name: "Install JDK 11"
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "11"
- name: "Install NPM"
uses: actions/setup-node@v1
- name: "NPM Build"
run: |
npm ci
npm run build --if-present
- name: "Run Unit Tests"
run: ./gradlew test
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: "Release"
on:
workflow_dispatch:
inputs:
dryRun:
description: "Do a dry run to preview instead of a real release [true/false]"
required: true
default: "false"

jobs:
semantic-release:
name: "Semantic Release"
runs-on: macos-latest
env:
GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-bot
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-bot
GIT_COMMITTER_EMAIL: developers@mparticle.com
steps:
- name: "Checkout public main branch"
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
# - name: "Import GPG Key"
# uses: crazy-max/ghaction-import-gpg@v4
# with:
# gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
# passphrase: ${{ secrets.GPG_PASSPHRASE }}
# git_user_signingkey: true
# git_commit_gpgsign: true
- name: "Semantic Release --dry-run"
if: ${{ github.event.inputs.dryRun == 'true' }}
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
semantic-release --dry-run
- name: "Semantic Release"
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
npx \
-p lodash \
-p semantic-release@17 \
-p @semantic-release/changelog@5 \
-p @semantic-release/git@9 \
-p @semantic-release/exec@5 \
semantic-release
- name: "Push automated release commits to release branch"
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push origin main
npm-release:
name: "Upload to NPM"
runs-on: ubuntu-latest
needs: semantic-release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
defaults:
run:
working-directory: ./plugin
steps:
- name: "Checkout public main branch"
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: main
- name: "Install Node"
uses: actions/setup-node@v1
- name: "NPM Build"
run: |
npm ci
npm run build --if-present
- name: "Upload to NPM"
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
touch .npmrc
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
npm publish
15 changes: 15 additions & 0 deletions .github/workflows/reusable-workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: "PR Reusable Checks"

on:
pull_request:

jobs:
pr-branch-check-name:
name: "Check PR for semantic branch name"
uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-check-name.yml@stable
pr-title-check:
name: "Check PR for semantic title"
uses: mParticle/mparticle-workflows/.github/workflows/pr-title-check.yml@stable
pr-branch-target-gitflow:
name: "Check PR for semantic target branch"
uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-target-continuous.yml@stable
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Built application files
*.apk
*.ap_
*.bak

# Files for the ART/Dalvik VM
*.dex
Expand Down
10 changes: 10 additions & 0 deletions .scripts/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
: ${1?"Version missing - usage: $0 x.y.z"}

#update build.gradle
line="\\\"version\\\":.*\\\".*\\\"/\\\"version\\\": \\\"$1\\\""

sed -i '.bak' "s/$line/g" plugin/package.json

#commit the version bump, tag, and push to private and public
git add plugin/package.json
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,28 +104,26 @@ Please see [Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) fo

2. Call `start` from the `onCreate` method of your app's `Application` class. It's crucial that the SDK be started here for proper session management. If you don't already have an `Application` class, create it and then specify its fully-qualified name in the `<application>` tag of your app's `AndroidManifest.xml`.

```java
```kotlin
package com.example.myapp;

import android.app.Application;
import com.mparticle.MParticle;

public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
MParticleOptions options = MParticleOptions.builder(this)
.credentials("REPLACE ME WITH KEY","REPLACE ME WITH SECRET")
.setLogLevel(MParticle.LogLevel.VERBOSE)
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val options: MParticleOptions = MParticleOptions.builder(this)
.credentials("REPLACE ME WITH KEY", "REPLACE ME WITH SECRET")
.logLevel(MParticle.LogLevel.VERBOSE)
.identify(identifyRequest)
.identifyTask(
new BaseIdentityTask()
.addFailureListener(this)
.addSuccessListener(this)
)
.build();

MParticle.start(options);
BaseIdentityTask()
.addFailureListener() { response -> }
.addSuccessListener { result -> }
)
.build()
MParticle.start(options)
}
}
```
Expand Down
23 changes: 0 additions & 23 deletions plugin/build.gradle

This file was deleted.

Empty file added plugin/build.gradle.kts
Empty file.
19 changes: 9 additions & 10 deletions plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
## For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# Default value: -Xmx1024m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
#Thu May 05 14:30:48 EDT 2022
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
2 changes: 1 addition & 1 deletion plugin/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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-4.6-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-all.zip
2 changes: 1 addition & 1 deletion plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</feature>
</config-file>
<source-file src="src/android/src/main/java/com/mparticle/cordova/MParticleCordovaPlugin.java" target-dir="src/android/src/main/java/com/mparticle/cordova/MParticleCordovaPlugin.java" />
<framework src="com.mparticle:android-core:5.27.0"/>
<framework src="com.mparticle:android-core:5.35.2"/>
</platform>
<platform name="ios">
<config-file target="config.xml" parent="/*">
Expand Down
1 change: 0 additions & 1 deletion plugin/settings.gradle

This file was deleted.

10 changes: 10 additions & 0 deletions plugin/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
include(":src:android")
pluginManagement {
repositories {
google()
mavenCentral()
}
plugins {
id("com.android.library") version ("7.1.3")
}
}
35 changes: 20 additions & 15 deletions plugin/src/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
apply plugin: 'com.android.library'
plugins {
id("com.android.library")
}

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
compileSdk = 31
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
minSdk = 15
targetSdk = 31
versionCode = 1
versionName = "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
}

}
repositories {
google()
mavenCentral()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testCompile 'org.json:json:20080701'
testCompile "org.mockito:mockito-core:1.+"
provided 'org.apache.cordova:framework:7.1.0'
provided 'com.mparticle:android-core:5.27.0'
compileOnly("org.apache.cordova:framework:10.1.2")
compileOnly("com.mparticle:android-core:5.38.1")

testImplementation("junit:junit:4.13.2")
testImplementation("org.json:json:20220320")
testImplementation("org.mockito:mockito-core:4.5.1")
testImplementation("org.apache.cordova:framework:10.1.2")
testImplementation("com.mparticle:android-core:5.38.1")
}
Loading

0 comments on commit 9365d33

Please sign in to comment.