habitica-android/Habitica/build.gradle

380 lines
15 KiB
Groovy
Raw Normal View History

2022-06-02 08:17:28 +00:00
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
id 'androidx.navigation.safeargs'
id 'com.google.firebase.firebase-perf'
2017-10-26 13:52:12 +00:00
}
2022-06-02 08:17:28 +00:00
apply plugin: 'kotlin-android'
2022-07-07 07:12:55 +00:00
apply plugin: "realm-android"
2022-06-02 08:17:28 +00:00
2017-10-26 13:52:12 +00:00
repositories {
mavenLocal()
mavenCentral()
2017-10-26 18:33:01 +00:00
google()
2017-10-26 13:52:12 +00:00
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url "https://jitpack.io" }
}
dependencies {
2022-07-05 15:31:03 +00:00
implementation fileTree(include: ['*.jar'], dir: '../common/libs')
2017-10-26 13:52:12 +00:00
//Networking
2022-06-10 08:03:36 +00:00
implementation "com.squareup.okhttp3:okhttp:$okhttp_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version"
2017-10-26 13:52:12 +00:00
//REST API handling
2022-06-10 08:03:36 +00:00
implementation("com.squareup.retrofit2:retrofit:$retrofit_version") {
2017-10-26 13:52:12 +00:00
exclude module: 'okhttp'
}
2022-06-10 08:03:36 +00:00
implementation "com.squareup.retrofit2:converter-gson:$retrofit_version"
2020-08-27 13:52:27 +00:00
2017-10-26 13:52:12 +00:00
//Dependency Injection
2022-06-10 08:03:36 +00:00
implementation "com.google.dagger:dagger:$daggerhilt_version"
kapt "com.google.dagger:dagger-compiler:$daggerhilt_version"
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
2017-10-26 13:52:12 +00:00
//App Compatibility and Material Design
2022-06-10 08:03:36 +00:00
implementation "androidx.appcompat:appcompat:$appcompat_version"
2023-02-13 13:24:37 +00:00
implementation 'com.google.android.material:material:1.8.0'
2022-06-10 08:03:36 +00:00
implementation "androidx.recyclerview:recyclerview:$recyclerview_version"
implementation "androidx.preference:preference-ktx:$preferences_version"
2022-07-27 11:04:16 +00:00
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
2021-06-08 06:59:17 +00:00
2022-04-18 02:28:07 +00:00
//Desugaring
2023-02-13 13:24:37 +00:00
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.2'
2021-06-08 06:59:17 +00:00
2023-02-13 13:24:37 +00:00
implementation('com.jaredrummler:android-device-names:2.1.1')
2022-01-13 14:33:07 +00:00
2017-10-26 13:52:12 +00:00
// IAP Handling / Verification
2022-11-17 13:19:21 +00:00
implementation "com.android.billingclient:billing-ktx:5.1.0"
2017-10-26 13:52:12 +00:00
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
2019-04-17 07:37:05 +00:00
2023-01-04 13:34:12 +00:00
implementation("io.coil-kt:coil-compose:$coil_version")
2017-10-26 13:52:12 +00:00
//Analytics
2022-11-17 13:19:21 +00:00
implementation "com.amplitude:analytics-android:$amplitude_version"
2021-09-17 07:21:20 +00:00
2017-10-26 13:52:12 +00:00
//Tests
2023-02-13 13:24:37 +00:00
testImplementation 'io.kotest:kotest-runner-junit5:5.5.5'
2023-01-04 13:34:12 +00:00
testImplementation 'androidx.test:core:1.5.0'
2023-02-13 13:24:37 +00:00
testImplementation 'io.mockk:mockk:1.13.4'
testImplementation 'io.mockk:mockk-android:1.13.4'
testImplementation 'io.kotest:kotest-assertions-core:5.5.5'
testImplementation 'io.kotest:kotest-framework-datatest:5.5.5'
androidTestImplementation ('com.kaspersky.android-components:kaspresso:1.5.1') {
2022-03-21 18:37:27 +00:00
exclude module: "protobuf-lite"
}
2023-02-13 13:24:37 +00:00
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
androidTestImplementation 'androidx.test:runner:1.5.2'
2023-01-04 13:34:12 +00:00
androidTestImplementation 'androidx.test:rules:1.5.0'
debugImplementation 'androidx.fragment:fragment-testing:1.5.5'
2023-02-13 13:24:37 +00:00
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
2023-01-04 13:34:12 +00:00
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
2023-02-13 13:24:37 +00:00
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
androidTestImplementation 'io.mockk:mockk-android:1.13.4'
androidTestImplementation 'io.kotest:kotest-assertions-core:5.5.5'
2023-01-04 13:34:12 +00:00
androidTestUtil("androidx.test:orchestrator:1.4.2")
2022-01-06 12:36:08 +00:00
2022-06-02 06:36:32 +00:00
implementation 'com.facebook.shimmer:shimmer:0.5.0'
2017-10-26 13:52:12 +00:00
//Leak Detection
2023-02-13 13:24:37 +00:00
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.10'
2017-10-26 13:52:12 +00:00
//Push Notifications
2022-07-27 11:04:16 +00:00
implementation platform("com.google.firebase:firebase-bom:$firebase_bom")
2023-02-13 13:24:37 +00:00
implementation 'com.google.firebase:firebase-analytics-ktx'
2021-11-19 10:42:49 +00:00
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-config-ktx'
implementation 'com.google.firebase:firebase-perf-ktx'
2023-02-13 13:24:37 +00:00
implementation 'com.google.android.gms:play-services-ads:21.5.0'
2022-06-10 08:03:36 +00:00
implementation "com.google.android.gms:play-services-auth:$play_auth_version"
2022-05-02 15:25:53 +00:00
implementation 'com.google.android.flexbox:flexbox:3.0.0'
2022-06-10 08:03:36 +00:00
implementation "com.google.android.gms:play-services-wearable:$play_wearables_version"
2018-11-06 15:11:02 +00:00
2022-06-10 08:03:36 +00:00
implementation "androidx.core:core-ktx:$core_ktx_version"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"
2022-09-26 11:05:22 +00:00
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
2022-12-20 12:36:34 +00:00
implementation "androidx.fragment:fragment-ktx:1.5.5"
2022-03-31 13:07:59 +00:00
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
2022-06-10 08:03:36 +00:00
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
2022-12-20 12:36:34 +00:00
implementation "com.google.accompanist:accompanist-themeadapter-material:$accompanist_version"
2022-11-17 18:01:54 +00:00
implementation "androidx.compose.material3:material3:1.0.1"
2022-12-20 12:36:34 +00:00
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
2022-09-26 11:05:22 +00:00
2022-10-31 14:12:55 +00:00
implementation 'androidx.activity:activity-compose:1.6.1'
2022-09-26 11:05:22 +00:00
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
2023-02-13 13:24:37 +00:00
implementation "androidx.compose.material:material:1.3.1"
2022-09-26 11:05:22 +00:00
implementation "androidx.compose.animation:animation:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
2022-10-07 11:22:56 +00:00
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
2021-01-26 15:49:52 +00:00
implementation 'com.willowtreeapps:signinwithapplebutton:0.3'
2020-01-21 13:54:17 +00:00
implementation project(':common')
implementation project(':shared')
2021-09-14 11:06:13 +00:00
2022-06-02 08:17:28 +00:00
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
2017-10-26 13:52:12 +00:00
}
android {
2022-06-10 08:03:36 +00:00
compileSdkVersion target_sdk
2023-02-13 13:24:37 +00:00
buildToolsVersion '33.0.2'
testOptions {
unitTests {
includeAndroidResources = true
}
2022-03-29 12:35:42 +00:00
animationsDisabled = true
}
2017-10-26 13:52:12 +00:00
defaultConfig {
2022-10-12 15:50:02 +00:00
minSdkVersion min_sdk
2017-10-26 13:52:12 +00:00
applicationId "com.habitrpg.android.habitica"
2018-12-10 12:36:30 +00:00
vectorDrawables.useSupportLibrary = true
2017-10-26 13:52:12 +00:00
buildConfigField "String", "STORE", "\"google\""
buildConfigField "String", "TESTING_LEVEL", "\"production\""
2022-07-26 11:27:06 +00:00
resConfigs 'en', 'bg', 'de', 'en-rGB', 'es', 'fr', 'hr-rHR', 'in', 'it', 'iw', 'ja', 'ko', 'lt', 'nl', 'pl', 'pt-rBR', 'pt-rPT', 'ru', 'tr', 'uk', 'zh', 'zh-rTW'
2018-11-05 12:57:42 +00:00
2022-06-27 09:20:19 +00:00
versionCode app_version_code
2022-06-10 08:03:36 +00:00
versionName app_version_name
2022-06-10 08:03:36 +00:00
targetSdkVersion target_sdk
2021-10-01 07:39:31 +00:00
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2022-03-31 13:07:59 +00:00
testInstrumentationRunnerArguments clearPackageData: 'true'
2022-07-07 13:54:17 +00:00
def formattedDate = new Date().format('yyMMdd')
archivesBaseName = "Habitica-${formattedDate}${versionCode}"
2017-10-26 13:52:12 +00:00
}
2020-10-06 07:29:45 +00:00
buildFeatures {
viewBinding true
2022-09-26 11:05:22 +00:00
compose true
}
composeOptions {
2023-02-13 13:24:37 +00:00
kotlinCompilerExtensionVersion = "1.4.2"
}
2017-10-26 13:52:12 +00:00
signingConfigs {
release
}
flavorDimensions "buildType"
buildTypes {
debug {
2023-01-09 15:35:04 +00:00
//applicationIdSuffix ".debug"
2017-10-26 13:52:12 +00:00
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
ext.alwaysUpdateBuildId = false
2022-03-21 18:37:27 +00:00
testCoverageEnabled = false
2023-01-09 15:35:04 +00:00
//resValue "string", "content_provider", "com.habitrpg.android.habitica.debug.fileprovider"
resValue "string", "content_provider", "com.habitrpg.android.habitica.fileprovider"
2017-10-26 13:52:12 +00:00
resValue "string", "app_name", "Habitica Debug"
}
debugIAP {
signingConfig signingConfigs.release
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// Disable fabric build ID generation for debug builds
ext.enableCrashlytics = false
ext.alwaysUpdateBuildId = false
resValue "string", "content_provider", "com.habitrpg.android.habitica.fileprovider"
resValue "string", "app_name", "Habitica Debug"
}
2017-10-26 13:52:12 +00:00
release {
signingConfig signingConfigs.release
2022-01-13 14:33:07 +00:00
debuggable false
2017-10-26 13:52:12 +00:00
minifyEnabled true
2019-09-19 08:52:30 +00:00
shrinkResources true
2017-10-26 13:52:12 +00:00
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
resValue "string", "content_provider", "com.habitrpg.android.habitica.fileprovider"
resValue "string", "app_name", "Habitica"
}
}
productFlavors {
dev {
dimension "buildType"
}
2020-04-22 12:52:46 +00:00
staff {
dimension "buildType"
buildConfigField "String", "TESTING_LEVEL", "\"staff\""
resValue "string", "app_name", "Habitica Staff"
2022-07-05 15:14:02 +00:00
versionCode app_version_code + 8
}
partners {
dimension "buildType"
buildConfigField "String", "TESTING_LEVEL", "\"partners\""
resValue "string", "app_name", "Habitica"
2022-06-27 09:20:19 +00:00
versionCode app_version_code + 6
2020-04-22 12:52:46 +00:00
}
2019-04-23 12:20:16 +00:00
alpha {
2018-12-04 15:54:39 +00:00
dimension "buildType"
buildConfigField "String", "TESTING_LEVEL", "\"alpha\""
resValue "string", "app_name", "Habitica Alpha"
2022-06-27 09:20:19 +00:00
versionCode app_version_code + 4
}
beta {
buildConfigField "String", "TESTING_LEVEL", "\"beta\""
dimension "buildType"
2022-06-27 09:20:19 +00:00
versionCode app_version_code + 2
2018-12-04 15:54:39 +00:00
}
2017-10-26 13:52:12 +00:00
prod {
buildConfigField "String", "TESTING_LEVEL", "\"production\""
2017-10-26 13:52:12 +00:00
dimension "buildType"
2022-06-27 09:20:19 +00:00
versionCode app_version_code
2017-10-26 13:52:12 +00:00
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/main/java']
resources.srcDirs = ['src/main/java']
aidl.srcDirs = ['src/main/java']
renderscript.srcDirs = ['src/main/java']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
2022-03-21 18:37:27 +00:00
test {
java.srcDir("src/test/java")
}
debugIAP { java.srcDirs = ['src/debug/java'] }
2017-10-26 13:52:12 +00:00
release { java.srcDirs = ['src/release/java'] }
}
compileOptions {
coreLibraryDesugaringEnabled true
2017-10-26 13:52:12 +00:00
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
2020-01-13 09:53:24 +00:00
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
2021-05-14 13:48:47 +00:00
bundle {
language {
// Specifies that the app bundle should not support
// configuration APKs for language resources. These
// resources are instead packaged with each base and
// dynamic feature APK.
enableSplit = false
}
}
2022-02-07 20:16:52 +00:00
lint {
abortOnError false
disable 'MissingTranslation', 'InvalidPackage'
enable 'LogConditional', 'IconExpectedSize', 'MissingRegistered', 'TypographyQuotes'
}
2017-10-26 13:52:12 +00:00
}
2021-09-17 07:21:20 +00:00
android.testOptions {
unitTests.all {
useJUnitPlatform()
2022-03-21 18:37:27 +00:00
testLogging {
events "passed", "skipped", "failed", "standardError"
outputs.upToDateWhen {false}
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
2021-09-17 07:21:20 +00:00
}
2022-03-31 13:07:59 +00:00
unitTests.returnDefaultValues = true
2021-09-17 07:21:20 +00:00
}
2017-10-26 13:52:12 +00:00
Properties props = new Properties()
def propFile = new File('signingrelease.properties')
if (propFile.canRead()) {
props.load(new FileInputStream(propFile))
if (props != null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) {
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
} else {
println 'signing.properties found but some entries are missing'
android.buildTypes.release.signingConfig = null
}
} else {
println 'signing.properties not found'
android.buildTypes.release.signingConfig = null
}
// Add Habitica Properties to buildConfigField
2022-03-31 13:07:59 +00:00
final File HRPG_PROPS_FILE = new File(projectDir.absolutePath + '/../habitica.properties')
2017-10-26 13:52:12 +00:00
if (HRPG_PROPS_FILE.canRead()) {
Properties HRPG_PROPS = new Properties()
HRPG_PROPS.load(new FileInputStream(HRPG_PROPS_FILE))
if (HRPG_PROPS != null) {
android.buildTypes.all { buildType ->
HRPG_PROPS.any { property ->
buildType.buildConfigField "String", property.key, "\"${property.value}\""
}
}
} else {
2022-06-02 08:17:28 +00:00
throw new MissingResourceException('habitica.properties found but some entries are missing')
2017-10-26 13:52:12 +00:00
}
} else {
throw new MissingResourceException('habitica.properties not found')
}
// Add Habitica Resources to resources
2022-03-31 13:07:59 +00:00
final File HRPG_RES_FILE = new File(projectDir.absolutePath + '/../habitica.resources')
2017-10-26 13:52:12 +00:00
if (HRPG_RES_FILE.canRead()) {
Properties HRPG_RES = new Properties()
HRPG_RES.load(new FileInputStream(HRPG_RES_FILE))
if (HRPG_RES != null) {
android.buildTypes.all { buildType ->
HRPG_RES.any { property ->
buildType.resValue "string", property.key, "\"${property.value}\""
}
}
} else {
2022-06-02 08:17:28 +00:00
throw new MissingResourceException('habitica.resources found but some entries are missing')
2017-10-26 13:52:12 +00:00
}
} else {
throw new MissingResourceException('habitica.resources not found')
}
tasks.whenTaskAdded { task ->
if (task.name == "lint") {
task.enabled = false
}
}
2018-11-06 13:04:27 +00:00
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xmaxerrs" << "500"
}
}
2023-02-13 13:24:37 +00:00
apply plugin: 'com.google.gms.google-services'