build.gradle 2.65 KB
Newer Older
1 2
import groovy.json.JsonSlurper

yogevbd's avatar
yogevbd committed
3 4 5
apply plugin: 'com.android.library'
apply from: '../prepare-robolectric.gradle'

6 7
String resolveFlavor() {
    def packageSlurper = new JsonSlurper()
yogevbd's avatar
yogevbd committed
8
    def reactNativePackageJson = packageSlurper.parse file('../../../node_modules/react-native/package.json')
9 10 11 12 13 14 15 16 17 18 19
    def reactNativeVersion = reactNativePackageJson.version

    List versionComponents = reactNativeVersion.tokenize('.')

    if (versionComponents[1].toInteger() < 60) {
        return "reactNative59"
    } else {
        return "reactNative60"
    }
}

yogevbd's avatar
yogevbd committed
20 21 22 23 24
android {
    compileSdkVersion 27
    buildToolsVersion '28.0.3'

    defaultConfig {
25
        minSdkVersion 16
yogevbd's avatar
yogevbd committed
26 27 28 29
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
30

yogevbd's avatar
yogevbd committed
31 32 33 34 35
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
36 37 38
        debug {
            debuggable true
        }
yogevbd's avatar
yogevbd committed
39
    }
40

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    testOptions {
        unitTests.all { t ->
            reports {
                html.enabled true
            }
            testLogging {
                events "PASSED", "SKIPPED", "FAILED", "standardOut", "standardError"
            }
            afterSuite { desc, result ->
                if (!desc.parent) { // will match the outermost suite
                    def output = "      ${result.resultType} (${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)     "
                    def repeatLength = output.length()
                    println '\n\n' + ('-' * repeatLength) + '\n' + output + '\n' + ('-' * repeatLength) + '\n'

                    println "see report at file://${t.reports.html.destination}/index.html"
                }
            }
        }
    }
60 61 62 63 64 65 66 67 68 69

    flavorDimensions "RNNotifications.reactNativeVersion"
    productFlavors {
        reactNative59 {
            dimension "RNNotifications.reactNativeVersion"
        }
        reactNative60 {
            dimension "RNNotifications.reactNativeVersion"
        }
    }
70 71 72 73 74 75 76 77

    def flavor = resolveFlavor()
    variantFilter { variant ->
        def names = variant.flavors*.name
        if (!names.contains(flavor)) {
            setIgnore(true)
        }
    }
yogevbd's avatar
yogevbd committed
78 79 80 81 82 83 84 85 86 87 88 89 90
}

dependencies {
    implementation "com.google.firebase:firebase-messaging:17.3.0"
    implementation 'com.facebook.react:react-native:+'

    // tests
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.robolectric:robolectric:3.5.1'
    testImplementation 'org.assertj:assertj-core:3.8.0'
    testImplementation 'com.squareup.assertj:assertj-android:1.1.1'
    testImplementation 'org.mockito:mockito-core:2.13.0'
}