SDP-GeoHunt/geo-hunt

View on GitHub
app/build.gradle

Summary

Maintainability
Test Coverage
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'org.jetbrains.kotlin.plugin.serialization'

    id 'jacoco'

    // Gradle Secrets (for Maps API key)
    id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}

android {
    namespace 'com.github.geohunt.app'
    compileSdk 33

    defaultConfig {
        applicationId "com.github.geohunt.app"
        minSdk 28
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        debug {
            testCoverageEnabled true
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

    buildFeatures {
        compose true
    }

    composeOptions {
        // Compose compiler to Kotlin version compability:
        // https://developer.android.com/jetpack/androidx/releases/compose-kotlin
        kotlinCompilerExtensionVersion '1.4.7'
    }

    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }

    testOptions {
        // Some dirty hack
        // see http://tools.android.com/tech-docs/unit-testing-support#TOC-Method-...-not-mocked.-
        unitTests.includeAndroidResources = true
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    // AndroidX dependencies
    implementation 'androidx.core:core-ktx:1.10.1'
    implementation 'androidx.activity:activity-compose:1.7.1'

    // AndroidX Lifecycle
    // https://developer.android.com/jetpack/androidx/releases/lifecycle
    def lifecycle_version = "2.6.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
    implementation "androidx.lifecycle:lifecycle-runtime-compose:$lifecycle_version"

    // Jetpack Compose dependencies
    // Compose BOM version mapping: https://developer.android.com/jetpack/compose/bom/bom-mapping
    implementation platform('androidx.compose:compose-bom:2023.05.00')
    implementation 'androidx.compose.material:material'
    implementation 'androidx.compose.material:material-icons-core'
    implementation 'androidx.compose.material:material-icons-extended'
    implementation 'androidx.compose.material3:material3'
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-tooling-preview'

    // Coil
    implementation 'io.coil-kt:coil:2.3.0'
    implementation 'io.coil-kt:coil-compose:2.3.0'

    // Google services
    implementation 'com.google.android.gms:play-services-auth:20.5.0'
    implementation 'com.google.android.gms:play-services-location:21.0.1'
    implementation 'com.google.android.gms:play-services-maps:18.1.0'

    // Google Maps dependencies
    implementation 'com.google.maps.android:maps-compose:2.11.4'
    implementation 'com.google.maps.android:maps-compose-widgets:2.11.4'

    // Firebase
    implementation platform('com.google.firebase:firebase-bom:32.0.0')
    implementation 'com.google.firebase:firebase-database-ktx'
    implementation 'com.google.firebase:firebase-storage-ktx'
    implementation 'com.google.firebase:firebase-auth-ktx'

    // Navigation
    implementation 'androidx.navigation:navigation-compose:2.5.3'
    implementation 'androidx.navigation:navigation-runtime-ktx:2.5.3'
    implementation 'androidx.navigation:navigation-testing:2.5.3'

    // Authentication
    implementation 'com.firebaseui:firebase-ui-auth:8.0.2'

    // Permissions
    implementation "com.google.accompanist:accompanist-permissions:0.30.1"

    // Settings
    implementation "androidx.datastore:datastore:1.0.0"
    implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1'

    // Permissions
    implementation "com.google.accompanist:accompanist-permissions:0.30.1"

    // Pager indicator
    implementation 'com.google.accompanist:accompanist-pager-indicators:0.30.1'

    //
    // Third-party libraries
    //

    // Settings UI
    implementation 'com.github.alorma:compose-settings-ui:0.27.0'

    // HTML text
    implementation 'com.github.ireward:compose-html:1.0.2'

    // Date Picker
    // Will be replaced by Material Design 3 DatePicker once implemented
    // Status: https://m3.material.io/components/date-pickers/overview#895df0e1-50dd-40bd-b398-d458e5a30bd0
    implementation 'com.maxkeppeler.sheets-compose-dialogs:core:1.1.1'
    implementation 'com.maxkeppeler.sheets-compose-dialogs:calendar:1.1.1'

    //
    // Tests
    //

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.hamcrest:hamcrest:2.2'
    testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1'
    androidTestImplementation 'androidx.test:core-ktx:1.5.0'
    // required if you want to use Mockito for unit tests
    testImplementation "org.mockito.kotlin:mockito-kotlin:4.1.0"
    testImplementation 'org.mockito:mockito-inline:5.2.0'
    // required if you want to use Mockito for Android tests
    androidTestImplementation "org.mockito.kotlin:mockito-kotlin:4.1.0"
    androidTestImplementation 'org.mockito:mockito-android:5.3.1'

    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation 'androidx.test.espresso:espresso-intents:3.5.1'
    androidTestImplementation 'androidx.test:runner:1.5.2'
    androidTestImplementation 'androidx.test:rules:1.5.0'
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.4.3'
    debugImplementation 'androidx.compose.ui:ui-tooling'
    debugImplementation 'androidx.compose.ui:ui-test-manifest'
}

tasks.withType(Test) {
    jacoco.includeNoLocationClasses = true
    jacoco.excludes = [
            'jdk.internal.*'
    ]
}

task buildTranslationArray {
    def foundLocales = new StringBuilder()
    def list = new ArrayList<String>()
    foundLocales.append("new String[]{")

    def translationParser = (new groovy.xml.XmlParser()).parse("./app/src/main/res/xml/locales_config.xml")
    translationParser.each {
        if (!it.attributes().values().empty) {
            def locale = it.attributes().values()[0]
            println "Found Locale: " + locale
            list.add(locale)
            foundLocales.append('"').append(locale).append("\", ")
        }
    }

    foundLocales.append("}")
    def foundLocalesString = foundLocales.toString().replaceAll(', }','}')
    println "Locales: " + foundLocalesString
    android.defaultConfig.buildConfigField "String[]", "TRANSLATION_ARRAY", foundLocalesString
}
preBuild.dependsOn buildTranslationArray

task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
    reports {
        xml.required = true
        html.required = true
    }

    def fileFilter = [
            '**/R.class',
            '**/R$*.class',
            '**/BuildConfig.*',
            '**/Manifest*.*',
            '**/*Test*.*',
            'android/**/*.*',
            '**/databinding/**/*.*',
            '**/*MapperImpl*.*',
            '**/BR.class',
            '**/DataBindingTriggerClass.class',
    ]

    def debugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
    def mainSrc = "$project.projectDir/src/main/java"

    sourceDirectories.setFrom(files([mainSrc]))
    classDirectories.setFrom(files([debugTree]))
    executionData.setFrom(fileTree(dir: project.buildDir, includes: [
            'outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec',
            'outputs/code_coverage/debugAndroidTest/connected/*/coverage.ec',
    ]))
}

connectedCheck {
    finalizedBy jacocoTestReport
}

apply plugin: 'com.google.gms.google-services'