aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: bdb527d96048415d8e8821c949343cba567fcb71 (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import versionbuilder.VersionBuilder

ext.androidBuildTools = '23.0.3'
ext.supportLibVersion = '23.2.1'
ext.AnySoftKeyboardApiVersion = '1.3.1'

ext.sdkTargetVersion = 23
ext.sdkCompileVersion = 23
ext.sdkMinimumVersion = 7

buildscript {
    repositories {
        mavenLocal()
        jcenter()
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url 'https://jitpack.io' }
        maven { url 'https://maven.fabric.io/public' }
        maven { url "https://plugins.gradle.org/m2/" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.0.0-beta7'
        classpath 'io.fabric.tools:gradle:1.21.4'
        classpath "net.ltgt.gradle:gradle-errorprone-plugin:0.0.8"
        classpath 'com.github.triplet.gradle:play-publisher:1.1.4'
    }
}

apply plugin: "net.ltgt.errorprone"
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
if (project.hasProperty("enableApkUpload")) {
    apply plugin: 'com.github.triplet.play'
}

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'pmd'
apply plugin: 'jacoco'

version VersionBuilder.buildGitVersionName()
group 'net.evendanan'

println "Building AnySoftKeyboard " + version

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

    compileSdkVersion sdkCompileVersion
    buildToolsVersion androidBuildTools

    defaultConfig {
        applicationId 'com.menny.android.anysoftkeyboard'
        versionCode VersionBuilder.buildGitVersionNumber()
        versionName project.version

        minSdkVersion sdkMinimumVersion
        targetSdkVersion sdkTargetVersion
        //adding additional fields to the BuildConfig class.

        def String support_email_address = System.getenv("ANYSOFTKEYBOARD_CRASH_REPORT_EMAIL")
        println 'crash report email is: ' + support_email_address

        buildConfigField "String", "CRASH_REPORT_EMAIL_ADDRESS", '"' + support_email_address + '"'

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    signingConfigs {
        release {
            if (file("anysoftkeyboard.keystore").exists()) {
                storeFile file("/tmp/anysoftkeyboard.keystore")
                storePassword System.getenv("ANYSOFTKEYBOARD_KEYSTORE_PASSWORD")
                keyAlias System.getenv("ANYSOFTKEYBOARD_KEYSTORE_ALIAS")
                keyPassword System.getenv("ANYSOFTKEYBOARD_KEYSTORE_KEY_PASSWORD")
                println "Using 'anysoftkeyboard.keystore' to release APK (with alias '${keyAlias}')."
            } else {
                println "Could not find 'anysoftkeyboard.keystore' file. Can not sign release APK."
            }
        }
    }

    buildTypes {
        release {
            signingConfig signingConfigs.release
            zipAlignEnabled true

            minifyEnabled true
            proguardFiles 'proguard-android-optimize.txt', 'proguard-rules.txt'

            ext.enableCrashlytics = false

            buildConfigField("boolean", "TESTING_BUILD", "false")
        }

        debug {
            zipAlignEnabled true
            debuggable true
            testCoverageEnabled true

            useLibrary 'org.apache.http.legacy'

            ext.enableCrashlytics = false
            buildConfigField("boolean", "TESTING_BUILD", "true")
        }

        canary {
            signingConfig signingConfigs.release
            zipAlignEnabled true

            minifyEnabled true
            proguardFiles 'proguard-android-optimize.txt', 'proguard-rules.txt'

            ext.enableCrashlytics = true
            buildConfigField("boolean", "TESTING_BUILD", "true")
        }
    }
}

task jacocoTestReport(type: JacocoReport/*make sure you are running testDebug prior to calling this task*/) {
    group = "Reporting"
    description = "Generate Jacoco coverage reports after running tests."
    reports {
        xml.enabled = true
        html.enabled = true
        csv.enabled = true
    }

    classDirectories = fileTree(
            dir: "$buildDir/intermediates/classes/debug",
            excludes: ['**/R*.class',
                       '**/*$InjectAdapter.class',
                       '**/*$ModuleAdapter.class',
                       '**/*$ViewInjector*.class'
            ])
    sourceDirectories = files(["$buildDir/src/main/java"])
    executionData = files("$buildDir/jacoco/testDebugUnitTest.exec")
    // Bit hacky but fixes https://code.google.com/p/android/issues/detail?id=69174.
    // We iterate through the compiled .class tree and rename $$ to $.
    doFirst {
        new File("$buildDir/intermediates/classes/").eachFileRecurse { file ->
            if (file.name.contains('$$')) {
                file.renameTo(file.path.replace('$$', '$'))
            }
        }
    }
}

configurations.errorprone {
    resolutionStrategy.force 'com.google.errorprone:error_prone_core:2.0.8'
}

if (project.hasProperty("enableApkUpload")) {
    play {
        track = 'beta'
        serviceAccountEmail = System.getenv("PUBLISH_APK_SERVICE_ACCOUNT_EMAIL")
        pk12File = file('/tmp/apk_upload_key.p12')
        uploadImages = false
    }
}

dependencies {
    repositories {
        mavenCentral()
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
        maven { url "https://jitpack.io" }
    }
    compile project(':base')
    compile project(':nextword')
    compile project(':jnidictionaryv1')
    compile project(':jnidictionaryv2')

    compile "com.github.AnySoftKeyboard:AnySoftKeyboard-API:$AnySoftKeyboardApiVersion"
    compile 'com.github.menny:FrankenRobot:1.1.5'
    compile "com.android.support:appcompat-v7:$supportLibVersion"
    compile "com.android.support:recyclerview-v7:$supportLibVersion"
    compile "com.android.support:support-annotations:$supportLibVersion"
    compile "com.android.support:palette-v7:$supportLibVersion"
    compile 'com.github.menny.Chauffeur:permissions:37ea0668afc7a63c6ea36f318741fb291fb2a20c'
    compile fileTree(dir: 'libs', include: '*.jar')

    testCompile 'junit:junit:4.12'
    testCompile 'org.robolectric:robolectric:3.0'
    testCompile 'org.mockito:mockito-core:1.9.5'
    canaryCompile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
        transitive = true;
    }
}