Skip to content

Commit

Permalink
Release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gouyelliot committed Mar 3, 2020
1 parent e92d981 commit 596f3aa
Show file tree
Hide file tree
Showing 19 changed files with 564 additions and 143 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Android CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Run CI
run: make ci
- name: Upload artifact
if: github.ref == 'refs/heads/master'
uses: actions/upload-artifact@v1
with:
name: google-analytics-dispatcher.zip
path: release/
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
/captures
.externalNativeBuild
.cxx
release/


/.idea/*
!/.idea/runConfigurations/
!/.idea/runConfigurations/
/maven.properties
/batch-maven-secret-gpg.key
21 changes: 21 additions & 0 deletions .idea/runConfigurations/build_aar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/runConfigurations/dispatcher_test.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1.0
-----

* Dispatcher release.
9 changes: 9 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright (c) 2014-Present, Batch.com

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:

- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

- Use of copies, substantial portions or binaries contained within Batch's SDK is only permitted to enable use of the Batch platform.

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.
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
all: aar

aar: clean
./gradlew assembleRelease --no-build-cache && \
mkdir -p release/ && \
cp google-analytics-dispatcher/build/outputs/aar/google-analytics-dispatcher-release.aar release/ && \
cp LICENSE release/

clean:
./gradlew clean

test:
./gradlew testDebugUnitTest

test-coverage:
./gradlew testDebugCoverageUnitTest && \
awk -F"," '{ instructions += $$4 + $$5; covered += $$5 } END { print covered, "/", instructions, "instructions covered"; print "Total", 100*covered/instructions "% covered" }' google-analytics-dispatcher/build/test-results/jacoco.csv

lint:
./gradlew lintDebug

ci: lint test-coverage aar
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.batch.android/google-analytics-dispatcher/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.batch.android/google-analytics-dispatcher)
[![Github Action](https://github.com/BatchLabs/android-google-analytics-dispatcher/workflows/Android%20CI/badge.svg)](https://github.com/BatchLabs/android-google-analytics-dispatcher/actions?query=workflow%3A%22Android+CI%22)

Batch.com Android Google Analytics Dispatcher
==================

![Logo](http://batch-doc.s3.amazonaws.com/logo_batch_192.gif)

# About

A "ready-to-go" dispatcher that reflect event from the Batch SDK to the Google Analytics dashboard using UTM tags.

# Requirements
- Android Studio 3.0+
- Android 15+
- Batch Android SDK 1.15.0+
- Play Services Analytics 17.0.0+

# Installation
Gradle (recommended)

```
implementation 'com.batch.android:google-analytics-dispatcher:1.0+'
```

Read our [setup documentation](https://doc.batch.com/) to follow a step by step tutorial for integrating Batch features into your app.

# Documentation

- [Technical](https://batch.com/doc)
- [FAQ](https://batch.com/doc/faq/general.html)
- [Developer FAQ](https://batch.com/developers)

Copyright 2020 - Batch.com
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.1'
classpath 'com.android.tools.build:gradle:3.6.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -18,9 +18,7 @@ allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
mavenLocal()
}
}

Expand Down
46 changes: 23 additions & 23 deletions google-analytics-dispatcher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
apply plugin: 'com.android.library'

ext {
mavenGroupId = 'com.batch.android'
mavenArtifact = 'google-analytics-dispatcher'
androidXLibraryVersion = '1.0.0'
}

android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
Expand All @@ -8,7 +14,7 @@ android {
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
versionName "1.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
Expand All @@ -19,41 +25,35 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

flavorDimensions "target-backend"

productFlavors {
production {
dimension "target-backend"
}

staging {
dimension "target-backend"
}
}

testOptions {
unitTests {
includeAndroidResources = true
all {
testLogging {
events "started", "passed", "skipped", "failed"
}
}
}
}

}

dependencies {
api(name:'Batch', ext:'aar')
//api 'com.batch.android:batch-sdk:[1.15,)' TODO remove aar and use maven repo after 1.15 release
api 'androidx.annotation:annotation:1.1.0'
api 'com.batch.android:batch-sdk:1.15.0'
api 'com.google.android.gms:play-services-analytics:17.0.0'
implementation "androidx.annotation:annotation:$androidXLibraryVersion"

testImplementation 'junit:junit:4.12'
testImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'org.mockito:mockito-core:2.25.1'
testImplementation 'org.robolectric:robolectric:4.3'
testImplementation 'org.mockito:mockito-core:3.2.4'
testImplementation 'org.robolectric:robolectric:4.3.1'
testImplementation 'androidx.test.espresso:espresso-core:3.2.0'

// We use PowerMock to mock GoogleAnalytics in tests
testImplementation 'org.powermock:powermock-module-junit4:2.0.2'
testImplementation 'org.powermock:powermock-module-junit4-rule:2.0.2'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'
testImplementation 'org.powermock:powermock-classloading-xstream:2.0.2'
testImplementation 'org.powermock:powermock-module-junit4:2.0.4'
testImplementation 'org.powermock:powermock-module-junit4-rule:2.0.4'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.4'
testImplementation 'org.powermock:powermock-classloading-xstream:2.0.4'
}

apply from: 'maven-publish.gradle'
apply from: 'jacoco.gradle'
89 changes: 89 additions & 0 deletions google-analytics-dispatcher/jacoco.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
apply plugin: 'jacoco'

configurations {
jacocoAnt
jacocoRuntime
}

jacoco {
toolVersion = '0.8.5'
}

def offline_instrumented_outputDir = "$buildDir.path/intermediates/classes-instrumented/debug"

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}

/* This task is used to create offline instrumentation of classes for on-the-fly instrumentation coverage tool like Jacoco. See jacoco classId
* and Offline Instrumentation from the jacoco site for more info.
*
* In this case, some classes mocked using PowerMock were reported as 0% coverage on jacoco & Sonarqube. The issue between PowerMock and jacoco
* is well documented, and a possible solution is offline Instrumentation (not so well documented for gradle).
*
* In a nutshell, this task:
* - Pre-instruments the original *.class files
* - Puts the instrumented classes path at the beginning of the task's classpath (for report purposes)
* - Runs test & generates a new exec file based on the pre-instrumented classes -- as opposed to on-the-fly instrumented class files generated by jacoco.
*
* It is currently not implemented to run prior to any other existing tasks (like test, jacocoTestReport, etc...), therefore, it should be called
* explicitly if Offline Instrumentation report is needed.
*
* Usage: gradle clean & gradle testDebugCoverageUnitTest
*/
task testDebugCoverageUnitTest(dependsOn: ['instrument', 'testDebugUnitTest']) {
doLast {
ant.taskdef(name: 'report',
classname: 'org.jacoco.ant.ReportTask',
classpath: configurations.jacocoAnt.asPath)
ant.report() {
executiondata {
ant.file(file: "$buildDir.path/jacoco/testDebugUnitTest.exec")
}
structure(name: 'DispatcherCoverage') {
classfiles {
fileset(
dir: "$buildDir/intermediates/javac/debug/classes",
excludes: '**/R.class,**/R$*.class,**/BuildConfig.*'
)
}
sourcefiles {
fileset(dir: 'src/main/java')
}
}

//html(destdir: "$buildDir.path/test-results/jacocoHtml")
csv(destfile: "$buildDir.path/test-results/jacoco.csv")
xml(destfile: "$buildDir.path/test-results/jacoco.xml")
}
}
}

/*
* Part of the Offline Instrumentation process is to add the jacoco runtime to the class path along with the path of the instrumented files.
*/
gradle.taskGraph.whenReady { graph ->
if (graph.hasTask(instrument)) {
tasks.withType(Test) {
doFirst {
systemProperty 'jacoco-agent.destfile', buildDir.path + '/jacoco/testDebugUnitTest.exec'
classpath = files(offline_instrumented_outputDir) + classpath + configurations.jacocoRuntime
}
}
}
}

/*
* Instruments the classes per se
*/
task instrument(dependsOn:'compileDebugUnitTestSources') {
doLast {
ant.taskdef(name: 'instrument',
classname: 'org.jacoco.ant.InstrumentTask',
classpath: configurations.jacocoAnt.asPath)

ant.instrument(destdir: offline_instrumented_outputDir) {
fileset(dir: "$buildDir.path/intermediates/javac/debug/classes")
}
}
}
Binary file removed google-analytics-dispatcher/libs/Batch.aar
Binary file not shown.
Loading

0 comments on commit 596f3aa

Please sign in to comment.