build.gradle 7.19 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

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

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

18
19
        def sentryDSN = String.valueOf(getSystemVariableOrDefault("NEBULO_SENTRY_DSN", "dummy"))
        def sentryConfigServer = String.valueOf(getSystemVariableOrDefault("NEBULO_SENTRY_CONFIGSERVER", "dummy"))
20
        buildConfigField("Boolean", "FROM_CI", String.valueOf(getSystemVariableOrDefault("CI_COMMIT_SHORT_SHA", "") != ""))
21
        buildConfigField("String", "COMMIT_HASH", '"' + getGitCommitHash() + '"')
22
23
        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
24
        buildConfigField("Boolean", "SHOW_DOQ", 'false')
Daniel Wolf's avatar
Daniel Wolf committed
25
        buildConfigField("Boolean", "SHOW_INTRO", 'false')
26
        buildConfigField("Boolean", "IN_APP_UPDATES", "false")
Daniel Wolf's avatar
Daniel Wolf committed
27
28
        buildConfigField("Boolean", "LEAK_DETECTION", "false")
        buildConfigField("Boolean", "SHOW_ALL_SERVERS", "true")
29

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

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

Daniel Wolf's avatar
Daniel Wolf committed
139
dependencies {
Daniel Wolf's avatar
Daniel Wolf committed
140
    def room_version = "2.3.0"
141

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

147

Daniel Wolf's avatar
Daniel Wolf committed
148
149
150
    implementation 'com.frostnerd.utilskt:lifecycle:1.2.2'
    implementation 'com.frostnerd.utilskt:preferences:1.5.31' // https://git.frostnerd.com/AndroidUtils/preferenceskt
    implementation 'com.frostnerd.utilskt:navigationdraweractivity:1.4.3' // https://git.frostnerd.com/AndroidUtils/navigationdraweractivity
151
    implementation 'com.frostnerd.utilskt:encrypteddnstunnelproxy:2.1.30' // https://git.frostnerd.com/AndroidUtils/encrypteddnstunnelproxy
Daniel Wolf's avatar
Daniel Wolf committed
152
153
    implementation 'com.frostnerd.utilskt:general:1.0.26' // https://git.frostnerd.com/AndroidUtils/generalkt
    implementation 'com.frostnerd.utilskt:adapters:1.3.5' // https://git.frostnerd.com/AndroidUtils/Adapters
Daniel Wolf's avatar
Daniel Wolf committed
154

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

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

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

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

Daniel Wolf's avatar
Daniel Wolf committed
171
    leakCanaryImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
Daniel Wolf's avatar
Daniel Wolf committed
172

Daniel Wolf's avatar
Daniel Wolf committed
173
    implementation "com.squareup.okhttp3:okhttp:4.9.1"
Daniel Wolf's avatar
Daniel Wolf committed
174
    implementation 'com.github.AppIntro:AppIntro:6.0.0'
Daniel Wolf's avatar
Daniel Wolf committed
175

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

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