/*
 * Copyright (C) 2017 The Android Open Source 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.
 */

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'

apply plugin: 'kotlin-allopen'
apply plugin: 'androidx.navigation.safeargs.kotlin'

allOpen {
    // allows mocking for classes w/o directly opening them for release builds
    annotation 'com.android.example.github.testing.OpenClass'
}
android {
    compileSdkVersion build_versions.compile_sdk
    defaultConfig {
        applicationId "com.android.example.github"
        minSdkVersion 21
        targetSdkVersion build_versions.target_sdk
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "com.android.example.github.util.GithubTestRunner"
    }
    buildTypes {
          debug {
              testCoverageEnabled !project.hasProperty('android.injected.invoked.from.ide')
          }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }
    sourceSets {
        androidTest.java.srcDirs += "src/test-common/java"
        test.java.srcDirs += "src/test-common/java"
    }
    lintOptions {
        lintConfig rootProject.file('lint.xml')
        disable 'InvalidPackage'
    }
}

dependencies {
    implementation deps.app_compat
    implementation deps.recyclerview
    implementation deps.cardview
    implementation deps.material
    implementation deps.core_ktx
    implementation deps.transition

    implementation deps.fragment.testing
    implementation deps.atsl.core

    implementation deps.navigation.fragment_ktx
    implementation deps.room.runtime
    implementation deps.lifecycle.livedata_ktx
    implementation deps.lifecycle.runtime
    implementation deps.lifecycle.java8
    implementation deps.retrofit.runtime
    implementation deps.retrofit.gson
    implementation deps.glide.runtime

    implementation deps.dagger.runtime
    implementation deps.dagger.android
    implementation deps.dagger.android_support
    implementation deps.constraint_layout
    implementation deps.kotlin.stdlib

    implementation deps.timber

    kapt deps.dagger.android_support_compiler
    kapt deps.dagger.compiler
    kapt deps.room.compiler
    kapt deps.lifecycle.compiler

    testImplementation deps.atsl.core
    testImplementation deps.junit
    testImplementation deps.mock_web_server
    testImplementation deps.arch_core.testing
    testImplementation deps.mockito.core

    androidTestImplementation deps.atsl.core
    androidTestImplementation deps.atsl.ext_junit
    androidTestImplementation deps.atsl.runner
    androidTestImplementation deps.atsl.rules

    androidTestImplementation deps.app_compat
    androidTestImplementation deps.recyclerview
    androidTestImplementation deps.cardview
    androidTestImplementation deps.material

    androidTestImplementation deps.espresso.core
    androidTestImplementation deps.espresso.contrib

    androidTestImplementation deps.arch_core.testing
    androidTestImplementation deps.mockito.core
    androidTestImplementation deps.mockito.android
}

// we need all open to run tests which we enable only for debug builds.
project.tasks.whenTaskAdded {
    if (it.name == "testReleaseUnitTest") {
        it.enabled = false
    }
}
