cook4me/android

View on GitHub
app/build.gradle

Summary

Maintainability
Test Coverage
plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id 'jacoco'
    id 'org.jlleitschuh.gradle.ktlint' version '10.0.0'
    id 'io.gitlab.arturbosch.detekt' version '1.20.0'
    id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
    id 'com.google.gms.google-services'
}

android {
    namespace 'ch.epfl.sdp.cook4me'
    compileSdk 33

    defaultConfig {
        // Read chat api key from local.properties
        def properties = new Properties()
        properties.load(project.rootProject.file('local.properties').newDataInputStream())
        def CHAT_API_KEY = properties.getProperty('CHAT_API_KEY', '')

        // Add API key as build config field
        buildConfigField 'String', 'CHAT_API_KEY', "\"${CHAT_API_KEY}\""

        applicationId 'ch.epfl.sdp.cook4me'
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName '1.0'

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

        manifestPlaceholders = [MAPS_API_KEY: "${project.findProperty('MAPS_API_KEY') ?: System.getProperty('MAPS_API_KEY')}"]

    }

    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 {
        kotlinCompilerExtensionVersion '1.2.0'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
    testCoverage {
        jacocoVersion = '0.8.8-SNAPSHOT'
    }

    testOptions {
        unitTests {
            all {
                systemProperty "android.test.logging", "verbose"
            }
        }
        packagingOptions {
            jniLibs {
                useLegacyPackaging true
            }
        }
    }

    lintOptions {
        baseline file("lint-baseline.xml")
        warningsAsErrors true
        checkTestSources true
    }
}

detekt {
    autoCorrect = true
    config = files('../detekt.yml')
}

jacoco {
    toolVersion = '0.8.8-SNAPSHOT'
}

configurations.forEach { config ->
    config.resolutionStrategy {
        eachDependency(p -> {
            if (p.getRequested().getGroup().equals('org.jacoco')) {
                p.useVersion('0.8.8-SNAPSHOT')
            }
        })
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.10.1'
    implementation 'io.coil-kt:coil-compose:2.2.2'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.1'
    implementation 'androidx.activity:activity-compose:1.7.2'
    implementation 'androidx.compose.ui:ui:1.4.3'
    implementation 'androidx.compose.ui:ui-tooling-preview:1.4.3'
    implementation 'androidx.compose.material:material:1.4.3'
    implementation 'com.google.maps.android:maps-compose:2.11.0'
    implementation 'com.google.android.gms:play-services-maps:18.1.0'
    implementation 'androidx.navigation:navigation-compose:2.5.3'
    implementation "com.google.code.gson:gson:2.9.0"
    implementation "androidx.navigation:navigation-compose:2.5.3"
    implementation "io.coil-kt:coil-compose:2.2.2"
    implementation "com.google.accompanist:accompanist-permissions:0.30.0"

    implementation 'com.alexstyl.swipeablecard:swipeablecard:0.1.0'

    implementation platform('com.google.firebase:firebase-bom:32.1.0')
    implementation 'com.google.firebase:firebase-auth-ktx'
    implementation 'com.google.firebase:firebase-firestore-ktx'
    implementation 'com.google.firebase:firebase-storage-ktx'

    implementation "io.getstream:stream-chat-android-compose:5.12.0"
    implementation "androidx.compose.material:material-icons-extended:1.4.3"
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

    testImplementation 'junit:junit:4.13.2'
    testImplementation('org.hamcrest:hamcrest:2.2')

    debugImplementation "androidx.compose.ui:ui-tooling:1.4.3"
    debugImplementation "androidx.compose.ui:ui-test-manifest:1.4.3"

    detektPlugins('io.gitlab.arturbosch.detekt:detekt-formatting:1.22.0')

    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.4.3"
    androidTestImplementation "androidx.navigation:navigation-testing:2.5.3"
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.4.3'
    androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.4.3'
    androidTestImplementation 'androidx.navigation:navigation-testing:2.5.3'
    //noinspection GradleDependency see: https://github.com/mockk/mockk/issues/297#issuecomment-901924678
    androidTestImplementation 'io.mockk:mockk-android:1.12.3'

    debugImplementation 'androidx.compose.ui:ui-tooling:1.4.3'
    debugImplementation 'androidx.compose.ui:ui-test-manifest:1.4.3'
}

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

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

    def fileFilter = [
            '**/R.class',
            '**/R$*.class',
            '**/BuildConfig.*',
            '**/Manifest*.*',
            '**/*Test*.*',
            'android/**/*.*',
            // Exclude Hilt generated classes
            '**/*Hilt*.*',
            'hilt_aggregated_deps/**',
            '**/*_Factory.class',
            '**/*_MembersInjector.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
}