summaryrefslogtreecommitdiff
path: root/android/java/MapboxGLAndroidSDKTestApp/build.gradle
blob: 5f2db91d7ed90a7ed77acc5d5cb447da5eb7865c (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
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.2'
        classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
    }
}

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

task accessToken {
    def rawDir = new File("MapboxGLAndroidSDKTestApp/src/main/res/raw")
    rawDir.mkdirs()
    def tokenFile = new File("MapboxGLAndroidSDKTestApp/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 22
    buildToolsVersion "22.0.1"

    repositories {
        mavenCentral()
    }

    defaultConfig {
        applicationId "com.mapbox.mapboxgl.testapp"
        minSdkVersion 8
        targetSdkVersion 22
        versionCode 4
        versionName "0.1.3"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

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

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

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

dependencies {
    compile(project(':MapboxGLAndroidSDK')) {
        transitive = true
    }
    compile 'com.android.support:support-annotations:22.1.1'
    compile 'com.android.support:support-v4:22.1.1'
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.mapzen.android:lost:1.0.0'
}

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
}