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

def repoRootPath = 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 24
        targetSdkVersion 30
        versionCode 21020099
        versionName "2021.2"
    }

    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/'
            }
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    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
            }
        }
    }
}

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

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

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

repositories {
    jcenter()
    google()
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation "androidx.constraintlayout:constraintlayout:2.0.4"
    implementation "androidx.fragment:fragment-ktx:1.3.0"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.0"
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'commons-validator:commons-validator:1.7'
    implementation 'joda-time:joda-time:2.10.2'
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"

    /* Test dependencies */
    testImplementation "io.mockk:mockk:$mockkVersion"
    testImplementation 'junit:junit:4.13'
    testImplementation "org.jetbrains.kotlin:kotlin-test:$kotlinVersion"
}

buildscript {
    ext {
        kotlinVersion = '1.4.10'
        mockkVersion = '1.10.6'
    }
    repositories {
        jcenter()
        google()

        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.1.2'
        classpath 'com.github.triplet.gradle:play-publisher:2.7.5'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.20'
    }
}

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