SmashKs/OneShoot

View on GitHub
presentation/build.gradle

Summary

Maintainability
Test Coverage
/*
 * Copyright (C) 2019 The Smash Ks Open Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import dependenices.Deps.Global
import dependenices.Deps.GlobalDebug
import dependenices.Deps.GlobalTest
import dependenices.Deps.Presentation
import dependenices.Deps.PresentationTest
import dependenices.Versions.Android

apply plugin: "com.android.application"
apply plugin: "kotlin-android"
apply plugin: "kotlin-android-extensions"
apply plugin: "kotlin-kapt"
apply plugin: "androidx.navigation.safeargs"
apply plugin: "jacoco"

android {
    compileSdkVersion Android.compileSdk
    defaultConfig {
        applicationId "smash.ks.com.oneshoot"
        minSdkVersion Android.minSdk
        targetSdkVersion Android.targetSdk
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        renderscriptTargetApi 28
        renderscriptSupportModeEnabled true    // Enable RS support
    }
    buildTypes {
        release {
            minifyEnabled = false
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            // Usage is `BuildConfig.CloudinaryUrl`
            buildConfigField "String", "CloudinaryUrl", getProps("cloudinary_url")
            // Usage is `@string/cloudinary_url`.
            resValue "string", "cloudinary_url", getProps("cloudinary_url")
        }
        debug {
            testCoverageEnabled = true
            buildConfigField "String", "CloudinaryUrl", getProps("cloudinary_url")
            resValue "string", "cloudinary_url", getProps("cloudinary_url")
        }
    }
    packagingOptions {
        exclude "META-INF/rxjava.properties"
        exclude "META-INF/main.kotlin_module"
        exclude "META-INF/kotlinx-coroutines-core.kotlin_module"
    }
    sourceSets {
        main {
            res.srcDirs += resources.FeatureRes.dirs
            jniLibs.srcDirs = ["libs"]
        }
    }
    dexOptions { javaMaxHeapSize "4g" }
    testOptions { unitTests.returnDefaultValues = true }
    aaptOptions { noCompress "tflite" }
    lintOptions { abortOnError false }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    ext { coverageSourceDirs = "src/test/java" }
}

androidExtensions { experimental = true }
kapt {
    correctErrorTypes = true
    useBuildCache = true
    mapDiagnosticLocations = true
}

dependencies {
    implementation fileTree(include: ["*.jar"], dir: "libs")
    implementation(project(":domain")) {
        exclude group: "org.reactivestreams"
    }
    implementation(project(":data")) {
        exclude group: "org.reactivestreams"
    }
    implementation project(":ext")

    implementation Presentation.dexTool

    //region Kotlin
    implementation Global.kotlin
    implementation Global.coroutine
    implementation Global.coroutinesRx2
    implementation Global.refelect
    implementation Presentation.androidCoroutine
    //endregion

    //region Reactive
    implementation Global.rxJava2
    implementation Global.rxKotlin
    //endregion

    //region Jieyi Libraries
    implementation Presentation.knifer
    implementation Presentation.arv
    implementation Presentation.quickDialog
    //endregion

    //region Anko
    implementation Presentation.anko
    implementation Presentation.ankoSdk25
    implementation Presentation.ankoV7
    implementation Presentation.ankoCoroutine
    implementation Presentation.ankoV7Coroutine
    //endregion

    //region Android extension
    implementation Presentation.ktx
    implementation Presentation.lifecycle
    //endregion

    //region Firebase & Database
    implementation Presentation.dbflow
    implementation(Presentation.firebaseCore) {
        exclude group: "com.android.support"
    }
    implementation(Presentation.firebaseDB) {
        exclude group: "com.android.support"
    }
    implementation(Presentation.firebaseVision) {
        exclude group: "com.android.support"
    }
    implementation(Presentation.firebaseMLImageLabel) {
        exclude group: "com.android.support"
    }
    implementation Presentation.tensorflowLite
    implementation Presentation.cloudinary
    //endregion

    //region Mapper
    implementation Presentation.modelMapper
    //endregion

    //region DI
    implementation Global.kodeinAndroidX
    implementation Global.kodeinJVM
    //endregion

    //region Rx Bus
    implementation(Presentation.rxBus) {
        exclude group: "com.jakewharton.timber", module: "timber"
    }
    //endregion

    //region Rx Lifecycle
    // We"re not using now. This"s just for the extensions.
    implementation Presentation.rxLifecycle
    //    implementation Presentation.rxLifecycleComponent
    //    implementation Presentation.rxPermission
    //endregion

    //region Internet & Image loading
    implementation Presentation.retrofit2
    implementation Presentation.retrofit2Gson
    implementation Presentation.retrofit2RxJava2
    implementation Presentation.okhttpLogging
    implementation Presentation.glide
    //endregion

    //region UI
    implementation Presentation.loading
    implementation Presentation.materialChip
    implementation Presentation.cameraView
    //endregion

    //region Androidx SDK
    implementation Presentation.appcompat
    implementation Presentation.materialDessign
    implementation Presentation.recyclerview
    implementation Presentation.cardview
    implementation Presentation.annot
    implementation Presentation.constraintLayout
    implementation Presentation.coordinatorLayout
    implementation Presentation.navigationUi
    implementation Presentation.navigationFragment
    //endregion

    //region Test
    testImplementation GlobalTest.kotlin
    testImplementation GlobalTest.junit
    testImplementation(GlobalTest.mockito) {
        exclude group: "org.mockito", module: "mockito-core"
    }
    testImplementation GlobalTest.assertj
    testImplementation GlobalTest.powerMockJunit
    testImplementation GlobalTest.powerMockito

    //region For the the newest version.
    testImplementation GlobalTest.byteBuddyAgent
    testImplementation GlobalTest.byteBuddyAndroid
    //endregion
    //endregion

    //region Android Test
    androidTestImplementation GlobalTest.kotlin
    androidTestImplementation "org.mockito:mockito-core:2.27.0"
    androidTestImplementation(PresentationTest.espressoHelper) {
        exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jre7"
    }

    //    androidTestImplementation PresentationTest.robolectric
    androidTestImplementation PresentationTest.kakao
    androidTestImplementation PresentationTest.mockkAndroid
    //endregion

    debugImplementation GlobalDebug.database
}

tasks.withType(Test) { jacoco.includeNoLocationClasses = true }
task jacocoTestReport(type: JacocoReport, dependsOn: ["testDebugUnitTest", "createDebugCoverageReport"]) {
    reports {
        xml.enabled = true
        html.enabled = true
    }

    def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
    def debugTree = fileTree(dir: "$project.buildDir/tmp/kotlin-classes/debug", excludes: fileFilter)
    def mainSrc = "$project.projectDir/src/main/kotlin"

    sourceDirectories = files([mainSrc])
    classDirectories = files([debugTree])
    executionData = fileTree(dir: project.buildDir, includes: [
            "jacoco/testDebugUnitTest.exec", "outputs/code-coverage/connected/*coverage.ec"
    ])
}

// Get a variable from local.properties.
def getProps(String propName) {
    def propsFile = rootProject.file("local.properties")

    if (!propsFile.exists()) return "\"No_Exist\""

    def props = new Properties()
    props.load(new FileInputStream(propsFile))

    if (null == props[propName]) return "\"There_is_no_parameter\""

    return props[propName]
}

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