build.gradle 7.23 KB
Newer Older
Daniel Wolf's avatar
Daniel Wolf committed
1
2
3
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
4
apply plugin: 'kotlin-kapt'
Daniel Wolf's avatar
Daniel Wolf committed
5
apply plugin: 'app.cash.exhaustive'
Daniel Wolf's avatar
Daniel Wolf committed
6

7
8
def debugKeyPath = new File(System.properties['user.home'], ".android/debug.keystore")

Daniel Wolf's avatar
Daniel Wolf committed
9
android {
Daniel Wolf's avatar
Daniel Wolf committed
10
    compileSdkVersion 30
Daniel Wolf's avatar
Daniel Wolf committed
11
12
13
    defaultConfig {
        applicationId "com.frostnerd.smokescreen"
        minSdkVersion 21
Daniel Wolf's avatar
Daniel Wolf committed
14
        targetSdkVersion 30
15
16
        versionCode 76
        versionName "2.0.5"
Daniel Wolf's avatar
Daniel Wolf committed
17
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
18

19
20
        def sentryDSN = String.valueOf(getSystemVariableOrDefault("NEBULO_SENTRY_DSN", "dummy"))
        def sentryConfigServer = String.valueOf(getSystemVariableOrDefault("NEBULO_SENTRY_CONFIGSERVER", "dummy"))
21
        buildConfigField("Boolean", "FROM_CI", String.valueOf(getSystemVariableOrDefault("CI_COMMIT_SHORT_SHA", "") != ""))
22
        buildConfigField("String", "COMMIT_HASH", '"' + getGitCommitHash() + '"')
23
24
        buildConfigField("String", "SENTRY_DSN", '"' + sentryDSN+ '"') // A valid Sentry DSN, or "dummy"
        buildConfigField("String", "SENTRY_DSN_CONFIGSERVER", '"' + sentryConfigServer + '"') // A host which returns a valid Sentry DSN on GET, or "dummy". If both are dummy Sentry is disabled.
Daniel Wolf's avatar
Daniel Wolf committed
25
        buildConfigField("Boolean", "SHOW_DOQ", 'false')
Daniel Wolf's avatar
Daniel Wolf committed
26
        buildConfigField("Boolean", "SHOW_INTRO", 'false')
27
        buildConfigField("Boolean", "IN_APP_UPDATES", "false")
Daniel Wolf's avatar
Daniel Wolf committed
28
29
        buildConfigField("Boolean", "LEAK_DETECTION", "false")
        buildConfigField("Boolean", "SHOW_ALL_SERVERS", "true")
30

31
32
33
34
35
36
37
38
39
40
        kapt {
            arguments {
                arg("room.schemaLocation", "$projectDir/schemas".toString())
            }
        }
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
41
42
43
        vectorDrawables {
            useSupportLibrary = true
        }
44
    }
45
46
47
    signingConfigs {
        fromVariablesOrDebug {
            storeFile new File(getSystemVariableOrDefault("KEYSTORE_FILE", debugKeyPath.path))
48
            storePassword getSystemVariableOrDefault("KEYSTORE_PASSWORD", "android")
49
50
51
52
53
54
55
56
57
58
            keyAlias = getSystemVariableOrDefault("KEYSTORE_KEY_NAME", "androiddebugkey")
            keyPassword getSystemVariableOrDefault("KEYSTORE_KEY_PASSWORD", "android")
        }
        release {
            storeFile new File(getSystemVariableOrDefault("KEYSTORE_FILE", ""))
            storePassword getSystemVariableOrDefault("KEYSTORE_PASSWORD", "")
            keyAlias = getSystemVariableOrDefault("KEYSTORE_KEY_NAME", "")
            keyPassword getSystemVariableOrDefault("KEYSTORE_KEY_PASSWORD", "")
        }
    }
59
60
    sourceSets {
        androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
61
        debug.assets.srcDirs += files("$projectDir/schemas".toString())
Daniel Wolf's avatar
Daniel Wolf committed
62
        fdroidofficial.res.srcDirs += "src/fdroid/res"
Daniel Wolf's avatar
Daniel Wolf committed
63
64
65
66
    }
    buildTypes {
        release {
            minifyEnabled true
Daniel Wolf's avatar
Daniel Wolf committed
67
68
            debuggable false
            shrinkResources true
69
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
70
            signingConfig signingConfigs.release
71
72
73
        }
        debug {
            initWith buildTypes.debug
Daniel Wolf's avatar
Daniel Wolf committed
74
        }
75
        leakCanary {
76
            matchingFallbacks = ['debug']
77
            initWith buildTypes.debug
78
            buildConfigField("Boolean", "LEAK_DETECTION", "true")
79
        }
80
81
82
83
84
85
        unsignedRelease {
            minifyEnabled true
            debuggable false
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
Daniel Wolf's avatar
Daniel Wolf committed
86
    }
Daniel Wolf's avatar
Daniel Wolf committed
87
    flavorDimensions "releaseChannel"
88
    productFlavors {
Daniel Wolf's avatar
Daniel Wolf committed
89
        store {
90
            matchingFallbacks = ['default']
Daniel Wolf's avatar
Daniel Wolf committed
91
92
93
94
95
            dimension "releaseChannel"
            buildConfigField("Boolean", "IN_APP_UPDATES", "true")
            buildConfigField("Boolean", "SHOW_ALL_SERVERS", "false")
        }
        fdroidofficial {
Daniel Wolf's avatar
Daniel Wolf committed
96
            matchingFallbacks = ['fdroid']
Daniel Wolf's avatar
Daniel Wolf committed
97
            dimension "releaseChannel"
98
            versionNameSuffix "-adblock"
99
            versionCode 77
100
        }
Daniel Wolf's avatar
Daniel Wolf committed
101
        fdroid {
102
            matchingFallbacks = ['default']
Daniel Wolf's avatar
Daniel Wolf committed
103
104
105
            dimension "releaseChannel"
            versionNameSuffix "-adblock"
            versionCode 77
106
107
        }
    }
Daniel Wolf's avatar
Daniel Wolf committed
108
    packagingOptions {
109
        exclude 'META-INF/library_release.kotlin_module'
Daniel Wolf's avatar
Daniel Wolf committed
110
    }
111
112
113
114
115
    testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }
116
117
118
119
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
Daniel Wolf's avatar
Daniel Wolf committed
120
121
    lintOptions{
        disable 'MissingTranslation'
122
        disable 'InvalidPeriodicWorkRequestInterval'
Daniel Wolf's avatar
Daniel Wolf committed
123
    }
Daniel Wolf's avatar
Daniel Wolf committed
124
125
126
127
    dependenciesInfo {
        includeInApk = false
        includeInBundle = false
    }
128
129
130
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }
Daniel Wolf's avatar
Daniel Wolf committed
131
132
}

133
134
135
136
137
138
139
// Uncomment to force a dependency version
//configurations.all {
//    resolutionStrategy {
//        force 'com.example:example:1.2.3'
//    }
//}

Daniel Wolf's avatar
Daniel Wolf committed
140
dependencies {
Daniel Wolf's avatar
Daniel Wolf committed
141
    def room_version = "2.2.6"
142

Daniel Wolf's avatar
Daniel Wolf committed
143
    implementation fileTree(dir: 'libs', include: ['*.jar'])
Daniel Wolf's avatar
Daniel Wolf committed
144
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION"
Daniel Wolf's avatar
Daniel Wolf committed
145
146
    implementation('org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.2')
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2'
Daniel Wolf's avatar
Daniel Wolf committed
147

148

Daniel Wolf's avatar
Daniel Wolf committed
149
    implementation 'com.frostnerd.utilskt:lifecycle:1.2.1'
Daniel Wolf's avatar
Daniel Wolf committed
150
    implementation 'com.frostnerd.utilskt:preferences:1.5.30' // https://git.frostnerd.com/AndroidUtils/preferenceskt
Daniel Wolf's avatar
Daniel Wolf committed
151
    implementation 'com.frostnerd.utilskt:navigationdraweractivity:1.4.2' // https://git.frostnerd.com/AndroidUtils/navigationdraweractivity
Daniel Wolf's avatar
Daniel Wolf committed
152
    implementation 'com.frostnerd.utilskt:encrypteddnstunnelproxy:2.1.24' // https://git.frostnerd.com/AndroidUtils/encrypteddnstunnelproxy
Daniel Wolf's avatar
Daniel Wolf committed
153
    implementation 'com.frostnerd.utilskt:general:1.0.25' // https://git.frostnerd.com/AndroidUtils/generalkt
154
    implementation 'com.frostnerd.utilskt:adapters:1.3.4' // https://git.frostnerd.com/AndroidUtils/Adapters
Daniel Wolf's avatar
Daniel Wolf committed
155

Daniel Wolf's avatar
Daniel Wolf committed
156
    implementation 'androidx.work:work-runtime:2.4.0'
Daniel Wolf's avatar
Daniel Wolf committed
157
    implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
Daniel Wolf's avatar
Daniel Wolf committed
158
    implementation "androidx.preference:preference:1.1.1"
Daniel Wolf's avatar
Daniel Wolf committed
159
    implementation "com.google.android.material:material:1.3.0-rc01"
160
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0-alpha01'
Daniel Wolf's avatar
Daniel Wolf committed
161
    implementation "androidx.core:core-ktx:1.3.2"
Daniel Wolf's avatar
Daniel Wolf committed
162

Daniel Wolf's avatar
Daniel Wolf committed
163
    implementation "androidx.room:room-runtime:$room_version"
164
    kapt "androidx.room:room-compiler:$room_version"
Daniel Wolf's avatar
Daniel Wolf committed
165
    implementation "androidx.room:room-coroutines:2.1.0-alpha04"
166
167
    testImplementation "androidx.room:room-testing:$room_version"

Daniel Wolf's avatar
Daniel Wolf committed
168
    implementation 'io.sentry:sentry-android:3.2.0'
Daniel Wolf's avatar
Daniel Wolf committed
169

170
    implementation 'com.github.jorgecastilloprz:fabprogresscircle:1.01@aar'
171

172
    leakCanaryImplementation 'com.squareup.leakcanary:leakcanary-android:2.6'
Daniel Wolf's avatar
Daniel Wolf committed
173

Daniel Wolf's avatar
Daniel Wolf committed
174
    implementation "com.squareup.okhttp3:okhttp:4.9.0"
Daniel Wolf's avatar
Daniel Wolf committed
175
    implementation 'com.github.AppIntro:AppIntro:6.0.0'
Daniel Wolf's avatar
Daniel Wolf committed
176
177

    implementation 'com.google.android.play:core:1.9.0'
Daniel Wolf's avatar
Daniel Wolf committed
178
}
179
180
181
182
183
184
185
186
187

def getGitCommitHash() {
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'rev-parse', '--short', 'HEAD'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}