build.gradle 9.8 KB
Newer Older
1
apply plugin: 'com.android.application'
mahendri.md's avatar
mahendri.md committed
2
apply from: '../config/quality.gradle'
3 4

import com.android.ddmlib.DdmPreferences
rahadi's avatar
rahadi committed
5

6 7 8
DdmPreferences.setTimeOut(60000)

ant.condition(property: 'os', value: 'windows') {
rahadi's avatar
rahadi committed
9
    os(family: 'windows')
10
}
rahadi's avatar
rahadi committed
11 12
ant.condition(property: 'os', value: 'unix') {
    os(family: 'unix')
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
}

// Build numbers were manually set until 1067
def LEGACY_BUILD_NUMBER_OFFSET = 1067

// Based on http://stackoverflow.com/questions/17097263#24121734
def getMasterCommitCount = { ->
    try {
        def stdout = new ByteArrayOutputStream()
        exec {
            switch (ant.properties.os) {
                case 'windows':
                    commandLine 'cmd', '/c', 'git', 'rev-list', '--first-parent', '--count', 'master'
                    break
                case 'unix':
                    commandLine 'git', 'rev-list', '--first-parent', '--count', 'master'
                    break
            }
            standardOutput = stdout
        }
        return Integer.parseInt(stdout.toString().trim())
    } catch (ignored) {
        return -1;
    }
}

def getVersionName = { ->
    try {
        def stdout = new ByteArrayOutputStream()
        exec {
            switch (ant.properties.os) {
                case 'windows':
                    commandLine 'cmd', '/c', 'git', 'describe', '--tags', '--dirty', '--always'
                    break
                case 'unix':
                    commandLine 'git', 'describe', '--tags', '--dirty', '--always'
                    break
            }
            standardOutput = stdout
        }
        return stdout.toString().trim()
    } catch (ignored) {
        return null;
    }
}

mahendri.md's avatar
mahendri.md committed
59 60 61 62 63 64
def secretsFile = file('secrets.properties')
def secrets = new Properties()
if (secretsFile.exists()) {
    secrets.load(new FileInputStream(secretsFile))
}

65
android {
rahadi's avatar
rahadi committed
66
    compileSdkVersion(26)
mahendri.md's avatar
mahendri.md committed
67
    buildToolsVersion('26.0.2')
68 69 70 71

    defaultConfig {
        applicationId('org.odk.collect.android')
        minSdkVersion(16)
rahadi's avatar
rahadi committed
72
        targetSdkVersion(26)
73 74 75 76
        versionCode LEGACY_BUILD_NUMBER_OFFSET + getMasterCommitCount()
        versionName getVersionName()
        testInstrumentationRunner('android.support.test.runner.AndroidJUnitRunner')
        multiDexEnabled true
mahendri.md's avatar
mahendri.md committed
77
        vectorDrawables.useSupportLibrary = true
78 79
    }

mahendri.md's avatar
mahendri.md committed
80 81 82 83 84 85 86 87 88 89 90
    signingConfigs {
        release {
            if (secrets.getProperty('RELEASE_STORE_FILE')) {
                storeFile file(secrets.getProperty('RELEASE_STORE_FILE'))
                storePassword secrets.getProperty('RELEASE_STORE_PASSWORD')
                keyAlias secrets.getProperty('RELEASE_KEY_ALIAS')
                keyPassword secrets.getProperty('RELEASE_KEY_PASSWORD')
            }
        }
    }

91
    buildTypes {
mahendri.md's avatar
mahendri.md committed
92
        // Release build for all forks
93
        release {
mahendri.md's avatar
mahendri.md committed
94 95 96 97
            if (secrets.getProperty('RELEASE_STORE_FILE')) {
                signingConfig signingConfigs.release
            }
            minifyEnabled(true)
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
        debug {
            debuggable(true)
            // Allows AndroidTest JaCoCo reports to be generated
            testCoverageEnabled(true)
        }
    }

    packagingOptions {
        // Pick first occurrence of any files that cause conflicts, as defined
        // in common.gradle
        pickFirst 'META-INF/DEPENDENCIES'
        pickFirst 'META-INF/LICENSE'
        pickFirst 'META-INF/LICENSE.txt'
        pickFirst 'META-INF/NOTICE'
        pickFirst 'META-INF/NOTICE.txt'
        pickFirst 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
        pickFirst 'META-INF/services/com.fasterxml.jackson.core.ObjectCodec'
        pickFirst 'META-INF/services/javax.ws.rs.ext.MessageBodyReader'
        pickFirst 'META-INF/services/javax.ws.rs.ext.MessageBodyWriter'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    dexOptions {
        javaMaxHeapSize '2048M'
    }
}

configurations.all {
    resolutionStrategy {
        cacheDynamicVersionsFor(0, 'seconds')
        cacheChangingModulesFor(0, 'seconds')
    }
    transitive = true
}

allprojects {
    tasks.withType(JavaCompile) {
        options.compilerArgs << '-Xlint:all'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: '*.jar')
rahadi's avatar
rahadi committed
147 148 149
    compile group: 'com.android.support', name: 'appcompat-v7', version: '26.1.0'
    compile group: 'com.android.support', name: 'design', version: '26.1.0'
    compile group: 'com.android.support', name: 'cardview-v7', version: '26.1.0'
150 151 152 153
    compile group: 'com.android.support', name: 'multidex', version: '1.0.1'
    compile group: 'com.google.android.gms', name: 'play-services-analytics', version: '10.0.1'
    compile group: 'com.google.android.gms', name: 'play-services-auth', version: '10.0.1'
    compile group: 'com.google.android.gms', name: 'play-services-maps', version: '10.0.1'
mahendri.md's avatar
mahendri.md committed
154
    compile group: 'com.google.android.gms', name: 'play-services-location', version: '10.0.1'
rahadi's avatar
rahadi committed
155
    compile(group: 'com.google.code.gson', name: 'gson', version: '2.6.2') {
156 157 158 159 160 161 162 163 164 165 166 167 168 169
        exclude group: 'org.apache.httpcomponents'
    }
    compile group: 'com.google.firebase', name: 'firebase-core', version: '10.0.1'
    compile group: 'com.google.firebase', name: 'firebase-crash', version: '10.0.1'
    compile(group: 'com.google.http-client', name: 'google-http-client', version: '1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile(group: 'com.google.oauth-client', name: 'google-oauth-client', version: '1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }

    compile group: 'commons-io', name: 'commons-io', version: '2.4'
    compile group: 'net.sf.kxml', name: 'kxml2', version: '2.3.0'
    compile group: 'net.sf.opencsv', name: 'opencsv', version: '2.3'
rahadi's avatar
rahadi committed
170
    compile(group: 'org.opendatakit', name: 'opendatakit-javarosa', version: '2.6.1') {
mahendri.md's avatar
mahendri.md committed
171 172
        exclude module: 'joda-time'
    }
173 174 175
    compile group: 'org.osmdroid', name: 'osmdroid-android', version: '5.6.4'
    compile group: 'org.slf4j', name: 'slf4j-android', version: '1.6.1-RC1'
    compile group: 'pub.devrel', name: 'easypermissions', version: '0.2.1'
rahadi's avatar
rahadi committed
176 177 178 179 180 181 182 183 184
    compile(group: 'com.google.api-client', name: 'google-api-client-android', version: '1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile(group: 'com.google.apis', name: 'google-api-services-drive', version: 'v3-rev64-1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile(group: 'com.google.apis', name: 'google-api-services-sheets', version: 'v4-rev463-1.22.0') {
        exclude group: 'org.apache.httpcomponents'
    }
185
    compile group: 'com.jakewharton.timber', name: 'timber', version: '4.5.1'
rahadi's avatar
rahadi committed
186 187
    compile group: 'com.android.support', name: 'customtabs', version: '26.1.0'
    compile group: 'com.android.support', name: 'support-v13', version: '26.1.0'
188 189
    compile group: 'com.google.zxing', name: 'core', version: '3.2.0'
    compile group: 'com.journeyapps', name: 'zxing-android-embedded', version: '3.5.0'
mahendri.md's avatar
mahendri.md committed
190 191 192 193 194 195 196 197
    compile group: 'net.danlew', name: 'android.joda', version: '2.9.9'

    // Real LeakCanary for debug builds only: notifications, analysis, etc
    debugCompile group: 'com.squareup.leakcanary', name: 'leakcanary-android', version: '1.5.4'
    // No-Op version of LeakCanary for release builds: no notifications, no analysis, nothing
    releaseCompile group: 'com.squareup.leakcanary', name: 'leakcanary-android-no-op', version: '1.5.4'
    testCompile group: 'com.squareup.leakcanary', name: 'leakcanary-android-no-op', version: '1.5.4'
    androidTestCompile group: 'com.squareup.leakcanary', name: 'leakcanary-android-no-op', version: '1.5.4'
198 199 200

    // Testing-only dependencies
    testCompile group: 'junit', name: 'junit', version: '4.12'
mahendri.md's avatar
mahendri.md committed
201 202 203 204 205 206 207 208 209 210 211
    testCompile group: 'org.mockito', name: 'mockito-core', version: '2.8.47'
    testCompile group: 'org.robolectric', name: 'robolectric', version: '3.4'
    testCompile group: 'org.robolectric', name: 'shadows-multidex', version: '3.3.2'
    androidTestCompile group: 'org.mockito', name: 'mockito-android', version: '2.11.0'
    androidTestCompile(group: 'com.android.support.test', name: 'runner', version: '1.0.1') {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    androidTestCompile(group: 'com.android.support.test.espresso', name: 'espresso-core', version: '3.0.1') {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs', module: 'jsr305'
    }
rahadi's avatar
rahadi committed
212
    androidTestCompile(group: 'com.android.support.test.espresso', name: 'espresso-intents', version: '3.0.1') {
mahendri.md's avatar
mahendri.md committed
213 214 215 216
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs', module: 'jsr305'
    }

mahendri.md's avatar
mahendri.md committed
217
    androidTestCompile group: 'com.squareup.okhttp3', name: 'mockwebserver', version: '3.6.0'
218

219 220
    // tempat custom dependencies capi-stis, supaya gampang updatenya
    // sudah ada ui-android, peta wb, revalidasi (soon)
mahendri.md's avatar
mahendri.md committed
221
    compile('com.mikepenz:materialdrawer:6.0.2@aar') {
222 223
        transitive = true
    }
mahendri.md's avatar
mahendri.md committed
224 225 226
    compile('com.mapbox.mapboxsdk:mapbox-android-sdk:5.0.2@aar') {
        transitive = true
    }
227
    compile project(':slidingmenu')
rahadi's avatar
rahadi committed
228
    compile project(':vsen_p')
229
    compile 'org.apache.commons:commons-lang3:3.6'
mahendri.md's avatar
mahendri.md committed
230
    compile 'com.getbase:floatingactionbutton:1.10.1'
rahadi's avatar
rahadi committed
231 232
    compile 'com.android.support:support-v4:26.1.0'
    compile 'com.android.support:recyclerview-v7:26.1.0'
233
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
maztohir's avatar
maztohir committed
234
    compile 'com.android.volley:volley:1.0.0'
mahendri.md's avatar
mahendri.md committed
235 236
    compile 'com.mapbox.mapboxsdk:mapbox-android-services:2.1.2'
    compile 'com.squareup.picasso:picasso:2.5.2'
237
    compile 'com.google.firebase:firebase-messaging:10.0.1'
238 239 240 241 242
}

// Must be at bottom to prevent dependency collisions
// https://developers.google.com/android/guides/google-services-plugin
apply plugin: 'com.google.gms.google-services'