summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
blob: f52309cab350e7be11adccef1faf20678e85e8a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'checkstyle'
apply plugin: 'devicefarm'

task accessToken {
    def tokenFile = new File("MapboxGLAndroidSDKTestApp/src/main/res/values/developer-config.xml")
    if (!tokenFile.exists()) {
        String tokenFileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
                "<resources>\n" +
                "    <string name=\"mapbox_access_token\">" + "$System.env.MAPBOX_ACCESS_TOKEN" + "</string>\n" +
                "</resources>"

        if (tokenFileContents == null) {
            throw new InvalidUserDataException("You must set the MAPBOX_ACCESS_TOKEN environment variable.")
        }
        tokenFile.write(tokenFileContents)
    }
}

gradle.projectsEvaluated {
    preBuild.dependsOn('accessToken')
}

ext {
    supportLibVersion = '23.4.0'
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.mapbox.mapboxsdk.testapp"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 9
        versionName "4.1.0"

        // Specify AndroidJUnitRunner as the default test instrumentation runner
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'LICENSE.txt'
    }

    lintOptions {
        checkAllWarnings true
        warningsAsErrors true
        disable 'IconDensities'
        disable 'InvalidPackage'
    }

    testOptions {
        unitTests.returnDefaultValues = true
    }

    buildTypes {
        debug {
            // run code coverage reports
            testCoverageEnabled = true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile(project(':MapboxGLAndroidSDK')) {
        transitive = true
    }

    // Support libraries
    compile "com.android.support:support-annotations:${supportLibVersion}"
    compile "com.android.support:support-v4:${supportLibVersion}"
    compile "com.android.support:appcompat-v7:${supportLibVersion}"
    compile "com.android.support:design:${supportLibVersion}"
    compile "com.android.support:recyclerview-v7:${supportLibVersion}"

    // Leak Canary
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta1'
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta1'

    // Mapbox Android Services
    compile('com.mapbox.mapboxsdk:mapbox-android-services:2.0.0-SNAPSHOT@aar') {
        transitive = true
    }

    // Testing dependencies
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    androidTestCompile "com.android.support:support-annotations:${supportLibVersion}"
    androidTestCompile 'com.android.support.test:runner:0.4.1'
    androidTestCompile 'com.android.support.test:rules:0.4.1'
    androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
}

checkstyle {
    configFile project.file('../checks.xml')
    showViolations true
}


def getAccessKeyDeviceFarm() {
    return hasProperty('AWS_ACCESS_KEY_ID_DEVICE_FARM') ? AWS_ACCESS_KEY_ID_DEVICE_FARM : ""
}

def getSecretAccessKeyDeviceFarm() {
    return hasProperty('AWS_SECRET_ACCESS_KEY_DEVICE_FARM') ? AWS_SECRET_ACCESS_KEY_DEVICE_FARM : ""
}

devicefarm {

    projectName "Mapbox GL Android" // required: Must already exists.
    devicePool "sanity" // optional: Defaults to "Top Devices"

    authentication {
        accessKey getAccessKeyDeviceFarm()
        secretKey getSecretAccessKeyDeviceFarm()
    }

    // optional block, radios default to 'on' state, all parameters optional
    devicestate {
        ///extraDataZipFile file("path/to/zip") // or ‘null’ if you have no extra data. Default is null.
        //auxiliaryApps files(file("path/to/app"), file("path/to/app2")) // or ‘files()’ if you have no auxiliary apps. Default is an empty list.
        wifi "on"
        bluetooth "off"
        gps "on"
        nfc "on"
        latitude 47.6204 // default
        longitude - 122.3491 // default
    }

    // Instrumentation
    // optional filter "my-filter"
    // See AWS Developer docs
    instrumentation {

    }
}


android.applicationVariants.all { variant ->
    def name = variant.buildType.name
    def checkstyle = project.tasks.create "checkstyle${name.capitalize()}", Checkstyle
    checkstyle.dependsOn variant.javaCompile
    checkstyle.source variant.javaCompile.source
    checkstyle.classpath = project.fileTree(variant.javaCompile.destinationDir)
    checkstyle.exclude('**/BuildConfig.java')
    checkstyle.exclude('**/R.java')
    project.tasks.getByName("check").dependsOn checkstyle
}