aboutsummaryrefslogtreecommitdiff
path: root/app/build.gradle
blob: dbc38c37f2a593a882221d75345cd0d6eb3e402b (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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
apply plugin: 'com.android.application'
apply plugin: 'com.bugsnag.android.gradle'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'com.gladed.androidgitversion'


buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath "com.moowork.gradle:gradle-node-plugin:${Versions.nodeGradle}"
    }
}

apply plugin: com.moowork.gradle.node.NodePlugin

apply from: '../spotless.gradle'
group = APP_GROUP

android {
    compileSdkVersion Versions.targetSdk
    buildToolsVersion kau.Versions.buildTools

    androidGitVersion {
        codeFormat = 'MMNNPPXX'
        format = '%tag%%-count%%-commit%'
        prefix 'v'
    }

    defaultConfig {
        applicationId "${project.APP_GROUP}.${project.APP_ID.toLowerCase(Locale.CANADA)}"
        minSdkVersion kau.Versions.minSdk
        targetSdkVersion Versions.targetSdk
        versionCode androidGitVersion.code()
        versionName androidGitVersion.name()
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/src/schemas".toString()]
            }
        }
    }

    applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${project.APP_ID}-${variant.buildType.name}.apk"
        }
    }

    lintOptions {
        warningsAsErrors true
        disable 'TrustAllX509TrustManager',
                'UnusedResources',
                'ContentDescription',
                'RtlSymmetry',
                'MissingTranslation'

        xmlReport false
        textReport true
        textOutput 'stdout'
    }

    dataBinding {
        enabled = true
    }

    def testKeystoreFile = file('../files/test.keystore')
    def testPropFile = file('../files/test.properties')
    def withTestSigning = testKeystoreFile.exists() && testPropFile.exists()

    def releaseKeystoreFile = file('../files/release.keystore')
    def releasePropFile = file('../files/release.properties')
    def withReleaseSigning = releaseKeystoreFile.exists() && releasePropFile.exists()

    signingConfigs {

        debug {
            storeFile file("../files/debug.keystore")
            storePassword "debugKey"
            keyAlias "debugKey"
            keyPassword "debugKey"
        }

        if (withTestSigning) {
            def testProps = new Properties()
            testPropFile.withInputStream { testProps.load(it) }

            test {
                storeFile testKeystoreFile
                storePassword testProps.getProperty('storePassword')
                keyAlias testProps.getProperty('keyAlias')
                keyPassword testProps.getProperty('keyPassword')
            }
        }

        if (withReleaseSigning) {
            def releaseProps = new Properties()
            releasePropFile.withInputStream { releaseProps.load(it) }

            release {
                storeFile releaseKeystoreFile
                storePassword releaseProps.getProperty('storePassword')
                keyAlias releaseProps.getProperty('keyAlias')
                keyPassword releaseProps.getProperty('keyPassword')
            }
        }

    }

    def compilerArgs = ["-Xuse-experimental=kotlin.Experimental" /*, "-XXLanguage:+InlineClasses"*/]

    buildTypes {
        debug {
            minifyEnabled false
            shrinkResources false
            applicationIdSuffix ".debug"
            versionNameSuffix "-debug"
            signingConfig signingConfigs.debug
            resValue "string", "frost_name", "Frost Debug"
            resValue "string", "frost_web", "Frost Web Debug"
            ext.enableBugsnag = false

            kotlinOptions.freeCompilerArgs += compilerArgs
        }
        releaseTest {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            applicationIdSuffix ".test"
            versionNameSuffix "-test"
            if (withTestSigning) signingConfig signingConfigs.test
            resValue "string", "frost_name", "Frost Test"
            resValue "string", "frost_web", "Frost Web Test"
        }
        release {
            minifyEnabled true
            shrinkResources true
            if (withReleaseSigning) signingConfig signingConfigs.release
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            resValue "string", "frost_name", "Frost"
            resValue "string", "frost_web", "Frost Web"
        }
    }

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
        test.java.srcDirs += 'src/test/kotlin'
        androidTest.java.srcDirs += 'src/androidTest/kotlin'
        main.assets.srcDirs += ['src/web/assets']
    }

    packagingOptions {
        pickFirst 'META-INF/core_release.kotlin_module'
        pickFirst 'META-INF/library_release.kotlin_module'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    testOptions.unitTests {
        includeAndroidResources = true
        // Don't throw runtime exceptions for android calls that are not mocked
        returnDefaultValues = true

        // Always show the result of every unit test, even if it passes.
        all {
            testLogging {
                events 'passed', 'skipped', 'failed', 'standardError'
            }
        }
    }

    androidExtensions {
        experimental = true
    }

}

node {
    version = '12.4.0'
    npmVersion = '6.9.0'
    download = true
    nodeModulesDir = file("${project.projectDir}/src/web")
}

task npmCi(type: NpmTask) {
    dependsOn npmSetup
    npmCommand = ["ci"]
}

task frostWebGen(type: NpmTask) {
    dependsOn npmCi
    group 'build'
    description 'Generate Frost web assets'
    args = ['run', 'compile']
}

preBuild.dependsOn(frostWebGen)

repositories {
    google()
    jcenter()
    maven { url "https://jitpack.io" }
}

dependencies {
    implementation 'androidx.exifinterface:exifinterface:1.0.0'

    androidTestImplementation kau.Dependencies.kotlinTest
    androidTestImplementation kau.Dependencies.espresso
    androidTestImplementation kau.Dependencies.testRules
    androidTestImplementation kau.Dependencies.testRunner
    androidTestImplementation kau.Dependencies.kotlinReflect

    testImplementation kau.Dependencies.kotlinTest
    testImplementation kau.Dependencies.kotlinReflect
    testImplementation kau.Dependencies.junit

    implementation kau.Dependencies.kotlin

    //noinspection GradleDependency
    implementation kau.Dependencies.kau('core', KAU)
    //noinspection GradleDependency
    implementation kau.Dependencies.kau('core-ui', KAU)
    //noinspection GradleDependency
    implementation kau.Dependencies.kau('adapter', KAU)
    //noinspection GradleDependency
    implementation kau.Dependencies.kau('fastadapter', KAU)
    //noinspection GradleDependency
    implementation kau.Dependencies.kau('about', KAU)
    //noinspection GradleDependency
    implementation kau.Dependencies.kau('colorpicker', KAU)
    //noinspection GradleDependency
    implementation kau.Dependencies.kau('mediapicker', KAU)
    //noinspection GradleDependency
    implementation kau.Dependencies.kau('kpref-activity', KAU)
    //noinspection GradleDependency
    implementation kau.Dependencies.kau('searchview', KAU)

    implementation "androidx.core:core-ktx:${Versions.ktx}"

    implementation "androidx.biometric:biometric:${Versions.andxBiometric}"

    implementation "org.koin:koin-android:${Versions.koin}"
    testImplementation "org.koin:koin-test:${Versions.koin}"
    androidTestImplementation "org.koin:koin-test:${Versions.koin}"

//    androidTestImplementation "io.mockk:mockk:${Versions.mockk}"

    implementation kau.Dependencies.coroutines

    implementation "org.apache.commons:commons-text:${Versions.apacheCommonsText}"

    implementation "com.devbrackets.android:exomedia:${Versions.exoMedia}"

    implementation kau.Dependencies.fastAdapter("extensions")

    //noinspection GradleDependency
    implementation kau.Dependencies.glide
    //noinspection GradleDependency
    kapt kau.Dependencies.glideKapt

    implementation "com.fasterxml.jackson.core:jackson-databind:${Versions.jackson}"

    //noinspection GradleDependency
    releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${Versions.leakCanary}"
    //noinspection GradleDependency
    releaseTestImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${Versions.leakCanary}"
    //noinspection GradleDependency
    debugImplementation "com.squareup.leakcanary:leakcanary-android:${Versions.leakCanary}"
//    testImplementation "com.squareup.leakcanary:leakcanary-android-no-op:${Versions.leakCanary}"

    implementation "com.github.Raizlabs.DBFlow:dbflow:${Versions.dbflow}"
    implementation "com.github.Raizlabs.DBFlow:dbflow-core:${Versions.dbflow}"
    kapt "com.github.Raizlabs.DBFlow:dbflow-processor:${Versions.dbflow}"
    implementation "com.github.Raizlabs.DBFlow:dbflow-kotlinextensions:${Versions.dbflow}"

    //Icons
    implementation kau.Dependencies.iconicsMaterial
    implementation kau.Dependencies.iconicsCommunity

    implementation "org.jsoup:jsoup:${Versions.jsoup}"

    implementation "com.squareup.okhttp3:okhttp:${Versions.okhttp}"
    implementation "com.squareup.okhttp3:logging-interceptor:${Versions.okhttp}"
    testImplementation "com.squareup.okhttp3:mockwebserver:${Versions.okhttp}"
    androidTestImplementation "com.squareup.okhttp3:mockwebserver:${Versions.okhttp}"

    implementation "co.zsmb:materialdrawer-kt:${Versions.materialDrawerKt}"

    implementation kau.Dependencies.bugsnag

    implementation "com.davemorrissey.labs:subsampling-scale-image-view:${Versions.scaleImageView}"

    implementation "androidx.room:room-ktx:${Versions.room}"
    implementation "androidx.room:room-runtime:${Versions.room}"
    kapt "androidx.room:room-compiler:${Versions.room}"
    testImplementation "androidx.room:room-testing:${Versions.room}"

}

// Validates code and generates apk
task createGithubReleaseApk(type: GradleBuild) {
    tasks = ['spotlessCheck',
             'lintRelease',
             'testReleaseUnitTest',
             'connectedAndroidTest',
             'assembleRelease']
}

def kotlinResolutions = ['kotlin-reflect',
                         'kotlin-stdlib',
                         'kotlin-stdlib-jdk7',
                         'kotlin-stdlib-jdk8',
                         'kotlin-test',
                         'kotlin-test-junit4',
                         'kotlin-test-junit5']

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'org.jetbrains.kotlin' && requested.name in kotlinResolutions) {
            details.useVersion kau.Versions.kotlin
        }
    }
}

apply plugin: 'com.bugsnag.android.gradle'