habitica-android/Habitica/build.gradle

424 lines
15 KiB
Groovy
Raw Normal View History

2017-10-26 13:52:12 +00:00
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
2017-10-26 18:33:01 +00:00
apply plugin: 'kotlin-kapt'
2021-07-27 09:27:43 +00:00
apply plugin: 'com.google.gms.google-services'
2020-08-27 13:52:27 +00:00
apply plugin: 'com.google.firebase.crashlytics'
2017-10-26 13:52:12 +00:00
apply plugin: 'realm-android'
apply plugin: 'androidx.navigation.safeargs'
apply plugin: 'com.google.firebase.firebase-perf'
2021-09-22 08:36:05 +00:00
apply plugin: 'jacoco'
2017-10-26 13:52:12 +00:00
buildscript {
repositories {
mavenLocal()
2018-11-06 15:11:02 +00:00
google()
2017-10-26 13:52:12 +00:00
mavenCentral()
}
dependencies {
2022-01-04 13:06:58 +00:00
classpath 'com.android.tools.build:gradle:7.0.4'
2017-10-26 13:52:12 +00:00
classpath 'net.sourceforge.pmd:pmd-java:5.5.3'
}
}
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" }
}
2021-09-14 11:06:13 +00:00
configurations {
ktlint
}
2017-10-26 13:52:12 +00:00
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//Networking
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
2017-10-26 13:52:12 +00:00
//REST API handling
2020-10-06 07:29:45 +00:00
implementation('com.squareup.retrofit2:retrofit:2.9.0') {
2017-10-26 13:52:12 +00:00
exclude module: 'okhttp'
}
2020-10-06 07:29:45 +00:00
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
2020-08-27 13:52:27 +00:00
2017-10-26 13:52:12 +00:00
//Dependency Injection
2022-01-06 12:36:08 +00:00
implementation 'com.google.dagger:dagger:2.40.5'
kapt 'com.google.dagger:dagger-compiler:2.40.5'
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
2021-11-29 16:03:17 +00:00
compileOnly 'com.github.pengrad:jdk9-deps:1.0'
2017-10-26 13:52:12 +00:00
//App Compatibility and Material Design
2021-11-19 10:42:49 +00:00
implementation 'androidx.appcompat:appcompat:1.4.0'
2021-07-27 09:27:43 +00:00
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
2021-06-08 06:59:17 +00:00
implementation "androidx.preference:preference-ktx:1.1.1"
2017-10-26 13:52:12 +00:00
// Markdown
implementation "io.noties.markwon:core:4.6.2"
implementation "io.noties.markwon:ext-strikethrough:4.6.2"
implementation "io.noties.markwon:image:4.6.2"
implementation "io.noties.markwon:recycler:4.6.2"
2017-10-26 13:52:12 +00:00
//Eventbus
2022-01-06 12:36:08 +00:00
implementation 'org.greenrobot:eventbus:3.3.1'
2017-10-26 13:52:12 +00:00
// IAP Handling / Verification
implementation "com.android.billingclient:billing-ktx:4.0.0"
2017-10-26 13:52:12 +00:00
//Facebook
2022-01-06 12:36:08 +00:00
implementation('com.facebook.android:facebook-android-sdk:12.2.0') {
2017-10-26 13:52:12 +00:00
transitive = true
}
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
//RxJava
2020-10-06 07:29:45 +00:00
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
2022-01-06 12:36:08 +00:00
implementation 'io.reactivex.rxjava3:rxjava:3.1.3'
2020-10-06 07:29:45 +00:00
implementation 'io.reactivex.rxjava3:rxkotlin:3.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
2022-01-06 12:36:08 +00:00
implementation "com.github.akarnokd:rxjava3-bridge:3.0.2"
2019-04-17 07:37:05 +00:00
2017-10-26 13:52:12 +00:00
//Analytics
2022-01-06 12:36:08 +00:00
implementation 'com.amplitude:android-sdk:3.35.1'
2021-06-07 14:09:57 +00:00
// Image Management Library
2021-10-08 09:54:09 +00:00
implementation("io.coil-kt:coil:1.4.0")
implementation("io.coil-kt:coil-gif:1.4.0")
2021-09-17 07:21:20 +00:00
2017-10-26 13:52:12 +00:00
//Tests
2022-01-06 12:36:08 +00:00
testImplementation 'io.kotest:kotest-runner-junit5:5.0.3'
2021-07-27 09:27:43 +00:00
testImplementation 'androidx.test:core:1.4.0'
2022-01-06 12:36:08 +00:00
testImplementation "io.mockk:mockk:1.12.2"
testImplementation "io.mockk:mockk-android:1.12.2"
testImplementation 'io.kotest:kotest-assertions-core:5.0.3'
2021-09-22 08:36:05 +00:00
testImplementation 'io.kotest:kotest-framework-datatest:4.6.2'
2022-01-06 12:36:08 +00:00
androidTestImplementation 'com.kaspersky.android-components:kaspresso:1.4.0'
2021-10-01 07:39:31 +00:00
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
2022-01-06 12:36:08 +00:00
androidTestImplementation "io.mockk:mockk-android:1.12.2"
implementation 'androidx.activity:activity-compose:1.4.0'
implementation 'androidx.compose.material:material:1.0.5'
implementation 'androidx.compose.animation:animation:1.0.5'
implementation 'androidx.compose.ui:ui-tooling:1.0.5'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0'
implementation "com.google.accompanist:accompanist-appcompat-theme:0.16.0"
2021-10-01 07:39:31 +00:00
2021-09-15 17:01:08 +00:00
2017-10-26 13:52:12 +00:00
//Leak Detection
2022-01-06 12:36:08 +00:00
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.8'
2017-10-26 13:52:12 +00:00
//Push Notifications
2021-11-19 10:42:49 +00:00
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.firebase:firebase-crashlytics-ktx'
2021-07-27 09:27:43 +00:00
implementation 'com.google.firebase:firebase-core'
2021-11-19 10:42:49 +00:00
implementation 'com.google.firebase:firebase-messaging-ktx'
implementation 'com.google.firebase:firebase-config-ktx'
implementation 'com.google.firebase:firebase-perf-ktx'
2022-01-06 12:36:08 +00:00
implementation 'com.google.android.gms:play-services-auth:20.0.0'
2018-08-09 12:37:53 +00:00
implementation 'com.nex3z:flow-layout:1.2.2'
2018-11-06 15:11:02 +00:00
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.4.0"
2021-05-25 12:00:50 +00:00
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
2018-11-09 15:35:06 +00:00
implementation 'com.plattysoft.leonids:LeonidsLib:1.3.2'
2021-11-19 10:42:49 +00:00
implementation "androidx.fragment:fragment-ktx:1.4.0"
implementation "androidx.paging:paging-runtime-ktx:3.1.0"
2022-01-06 12:36:08 +00:00
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0'
2021-01-26 15:49:52 +00:00
implementation 'com.willowtreeapps:signinwithapplebutton:0.3'
2020-01-21 13:54:17 +00:00
implementation project(':shared')
2021-09-14 11:06:13 +00:00
2022-01-06 12:36:08 +00:00
ktlint("com.pinterest:ktlint:0.43.2") {
2021-09-14 11:06:13 +00:00
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, getObjects().named(Bundling, Bundling.EXTERNAL))
}
}
2017-10-26 13:52:12 +00:00
}
android {
2022-01-06 12:36:08 +00:00
compileSdkVersion 32
buildToolsVersion '30.0.2'
testOptions {
unitTests {
includeAndroidResources = true
}
}
2017-10-26 13:52:12 +00:00
defaultConfig {
2019-02-27 15:24:59 +00:00
minSdkVersion 21
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\""
2019-09-19 08:50:47 +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", "zh", "zh-rTW"
2018-11-05 12:57:42 +00:00
versionCode 3200
2022-01-06 12:36:08 +00:00
versionName "3.5"
2022-01-06 12:36:08 +00:00
targetSdkVersion 32
2021-10-01 07:39:31 +00:00
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2017-10-26 13:52:12 +00:00
}
2020-10-06 07:29:45 +00:00
buildFeatures {
viewBinding true
}
2017-10-26 13:52:12 +00:00
lintOptions {
abortOnError false
}
2019-11-05 14:19:44 +00:00
2017-10-26 13:52:12 +00:00
signingConfigs {
release
}
flavorDimensions "buildType"
buildTypes {
debug {
applicationIdSuffix ".debug"
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
2021-10-01 07:39:31 +00:00
testCoverageEnabled = true
2017-10-26 13:52:12 +00:00
resValue "string", "content_provider", "com.habitrpg.android.habitica.debug.fileprovider"
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
testCoverageEnabled = true
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
debuggable true
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"
}
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"
}
beta {
buildConfigField "String", "TESTING_LEVEL", "\"beta\""
dimension "buildType"
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"
}
}
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']
}
2018-07-05 11:24:58 +00:00
/*robolectric {
2017-10-26 13:52:12 +00:00
manifest.srcFile 'AndroidManifestTesting.xml'
java.srcDir file('src/test/java/')
res.srcDirs = ['res']
2018-07-05 11:24:58 +00:00
}*/
//instrumentTest.setRoot('tests')
debugIAP { java.srcDirs = ['src/debug/java'] }
2017-10-26 13:52:12 +00:00
release { java.srcDirs = ['src/release/java'] }
}
compileOptions {
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()
}
2017-10-26 13:52:12 +00:00
lintOptions {
disable 'MissingTranslation','InvalidPackage'
enable 'LogConditional','IconExpectedSize','MissingRegistered','TypographyQuotes'
}
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
}
}
2017-10-26 13:52:12 +00:00
}
2021-09-17 07:21:20 +00:00
android.testOptions {
unitTests.all {
useJUnitPlatform()
2021-09-22 08:36:05 +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
final File HRPG_PROPS_FILE = new File('habitica.properties')
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 {
throw new InvalidUserDataException('habitica.properties found but some entries are missing')
}
} else {
throw new MissingResourceException('habitica.properties not found')
}
// Add Habitica Resources to resources
final File HRPG_RES_FILE = new File('habitica.resources')
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 {
throw new InvalidUserDataException('habitica.resources found but some entries are missing')
}
} 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"
}
}
2020-09-04 16:17:34 +00:00
apply plugin: 'com.google.gms.google-services'
2021-09-14 11:06:13 +00:00
2021-09-22 08:36:05 +00:00
jacoco {
toolVersion = "0.8.7"
}
// packages to exclude for example generated classes, R class and models package, add all packages that you wish to exclude from test coverage
def fileFilter = [
'**/*$ViewInjector*.*','**/*$ViewBinder*.*', '**/HabiticaIcons*.*', '**/DeviceName.*', '**/databinding/*Binding.*',
'**/R.class', '**/R.styleable', '**/R$*.class', '**/BuildConfig.*', '**/EmojiMap.*',
'**/Manifest*.*', 'android/**/*.*', '**/*RealmProxy*.*', '**/io/realm/*']
def debugTree = fileTree(dir: "${buildDir}/intermediates/asm_instrumented_project_classes/prodDebug", excludes: fileFilter)
def mainSrc = "${project.projectDir}/src/main/java"
// override jacocTestReport task
task jacocoTestReport(type: JacocoReport, dependsOn: 'testProdDebugUnitTest') {
group = "Reporting"
reports {
html.enabled = true
xml.enabled = true
//html.destination = "${buildDir}/reports/jacoco"
}
sourceDirectories.from(files([mainSrc]))
classDirectories.from(files([debugTree]))
2021-10-01 07:39:31 +00:00
executionData.from(fileTree(dir: project.buildDir, includes: [
"${buildDir}/jacoco/testProdDebugUnitTest.exec",
"${buildDir}/outputs/code-coverage/connected/*coverage.ec"
]))
2021-09-22 08:36:05 +00:00
afterEvaluate {
classDirectories.from(files(classDirectories.files.collect {
fileTree(dir: it, exclude: fileFilter)
}))
}
}
2021-09-14 11:06:13 +00:00
task ktlint(type: JavaExec, group: "verification") {
description = "Check Kotlin code style."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "--disabled_rules=no-wildcard-imports", "--reporter=plain?group_by_file", "src/**/*.kt"
// to generate report in checkstyle format prepend following args:
// "--reporter=plain", "--reporter=checkstyle,output=${buildDir}/ktlint.xml"
// to add a baseline to check against prepend following args:
// "--baseline=ktlint-baseline.xml"
// see https://github.com/pinterest/ktlint#usage for more
}
check.dependsOn ktlint
task ktlintFormat(type: JavaExec, group: "formatting") {
description = "Fix Kotlin code style deviations."
classpath = configurations.ktlint
main = "com.pinterest.ktlint.Main"
args "--disabled_rules=no-wildcard-imports", "-F", "src/**/*.kt"
2021-10-01 07:39:31 +00:00
}