summaryrefslogtreecommitdiffhomepage
path: root/android/app/build.gradle
blob: 95f3b40d55b100a4fa332257ae8603dd47682f63 (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
apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'

def repoRootPath = rootProject.projectDir.absoluteFile.parentFile.absolutePath
def extraAssetsDirectory = "$project.buildDir/extraAssets"
def extraJniDirectory = "$project.buildDir/extraJni"

def keystorePropertiesFile = file('keystore.properties')
def keystoreProperties = new Properties()

if (keystorePropertiesFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}

android {
    compileSdkVersion 30
    buildToolsVersion '30.0.3'

    defaultConfig {
        applicationId "net.mullvad.mullvadvpn"
        minSdkVersion 26
        targetSdkVersion 30
        versionCode 21010099
        versionName "2021.1"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    if (keystorePropertiesFile.exists()) {
        signingConfigs {
            release {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
            }
        }

        buildTypes {
            release {
                minifyEnabled false
                signingConfig signingConfigs.release
            }
        }
    }

    buildTypes {
        fdroid {
            initWith release
            minifyEnabled false
            signingConfig null
        }
    }

    sourceSets {
        main {
            assets {
                srcDirs = files(extraAssetsDirectory)
            }

            jniLibs {
                srcDirs = files(extraJniDirectory)
            }

            java {
                srcDirs += 'src/main/kotlin/'
            }
        }

        test {
            java {
                srcDirs += 'src/test/kotlin/'
            }
        }

        androidTest {
            java {
                srcDirs += 'src/androidTest/kotlin/'
            }
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
        freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
        // Opt-in option for Koin annotation of KoinComponent.
    }

    applicationVariants.all { variant ->
        variant.mergeAssetsProvider.configure {
            dependsOn copyExtraAssets
        }
    }

    testOptions {
        unitTests.all {
            testLogging {
                outputs.upToDateWhen { false }
                events "passed", "skipped", "failed", "standardOut", "standardError"
                showCauses true
                showExceptions true
            }
        }
    }
}

dependencyCheck {
    // Skip the lintClassPath configuration, which relies on many dependencies that has been flagged
    // to have CVEs, as it's related to the lint tooling rather than the project's compilation class
    // path. The alternative would be to suppress specific CVEs, however that could potentially
    // result in suppressed CVEs in project compilation class path.
    skipConfigurations += 'lintClassPath'
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
    kotlinOptions {
        allWarningsAsErrors = false

        kotlinOptions.freeCompilerArgs += [
                "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
                "-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi",
        ]
    }
}

task copyExtraAssets(type: Copy) {
    from "$repoRootPath/dist-assets"
    include "relays.json"
    include "api-ip-address.txt"
    into extraAssetsDirectory
}

play {
    serviceAccountCredentials = file("play-api-key.json")
}

dependencies {
    implementation "androidx.appcompat:appcompat:1.3.1"
    implementation "androidx.constraintlayout:constraintlayout:2.1.0"
    implementation "androidx.coordinatorlayout:coordinatorlayout:1.1.0"
    implementation "androidx.core:core-ktx:1.6.0"
    implementation "androidx.fragment:fragment-ktx:$fragmentVersion"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
    implementation "androidx.recyclerview:recyclerview:1.2.1"
    implementation "com.google.android.material:material:1.4.0"
    implementation "commons-validator:commons-validator:1.7"
    implementation "io.insert-koin:koin-core:$koinVersion"
    implementation "io.insert-koin:koin-core-ext:$koinVersion"
    implementation "io.insert-koin:koin-androidx-fragment:$koinVersion"
    implementation "io.insert-koin:koin-androidx-scope:$koinVersion"
    implementation "io.insert-koin:koin-androidx-viewmodel:$koinVersion"
    implementation "joda-time:joda-time:2.10.2"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1"

    /* Test dependencies */
    testImplementation "io.insert-koin:koin-test:$koinVersion"
    testImplementation "io.mockk:mockk:$mockkVersion"
    testImplementation "junit:junit:4.13"
    testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
    testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.5.1"

    /* UI test dependencies */
    debugImplementation "androidx.fragment:fragment-testing:$fragmentVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
    androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
    androidTestImplementation "androidx.test.ext:junit:1.1.3"
    androidTestImplementation "io.mockk:mockk-android:$mockkVersion"
    androidTestImplementation "io.insert-koin:koin-test:$koinVersion"
    androidTestImplementation "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
}