summaryrefslogtreecommitdiff
path: root/android/MapboxGLAndroidSDKTestApp/build.gradle
blob: fbfc00376fb0fa4afa77cac7c1b2a6cfe1158925 (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
buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'checkstyle'

task accessToken {
    def rawDir = new File("MapboxGLAndroidSDK/src/main/res/raw")
    rawDir.mkdirs()
    def tokenFile = new File("MapboxGLAndroidSDK/src/main/res/raw/token.txt")
    if (!tokenFile.exists()) {
        String token = "$System.env.MAPBOX_ACCESS_TOKEN"
        if (token == null) {
            throw new InvalidUserDataException("You must set the MAPBOX_ACCESS_TOKEN environment variable.")
        }
        tokenFile.write(token)
    }
}

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.mapbox.mapboxgl.testapp"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 6
        versionName "2.2.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'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile(project(':MapboxGLAndroidSDK')) {
        transitive = true
    }
    compile 'com.android.support:support-annotations:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
        transitive = true;
    }

    // Testing dependencies
    testCompile 'junit:junit:4.12'
    testCompile 'org.mockito:mockito-core:1.10.19'
    androidTestCompile 'com.android.support:support-annotations:23.1.0'
    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
}

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
}