apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
//aspectj
apply plugin: 'android-aspectjx'

android {
    compileSdkVersion 28
    buildToolsVersion rootProject.buildToolsVersion
    defaultConfig {
        applicationId "com.ditclear.paonet"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

    signingConfigs {
        config {
            keyAlias 'paonet'
            keyPassword '111111'
            storeFile file('debug-keystore.jks')
            storePassword '111111'
        }
    }

    buildTypes {
        debug {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
    }

    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }

    dataBinding {
        enabled = true
    }
}
aspectjx {

    exclude 'android.support'
}

repositories {
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    mavenCentral()
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.0.0'
    implementation 'androidx.palette:palette:1.0.0'
    implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
    //ViewModel
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0-rc01'
    implementation 'androidx.lifecycle:lifecycle-viewmodel:2.0.0-rc01'
    kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0-rc01'
    //kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //aspectj
    implementation 'org.aspectj:aspectjrt:1.8.13'
    //rx android
    implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.2'
    //autodispose
    implementation 'com.uber.autodispose:autodispose:0.8.0'
    implementation 'com.uber.autodispose:autodispose-android-archcomponents:0.8.0'
    implementation 'com.google.android:flexbox:0.3.1'
    //di
    implementation "org.koin:koin-android-viewmodel:$koin_version"
    //retrofit
    implementation 'com.squareup.retrofit2:retrofit:' + rootProject.retrofitVersion
    implementation 'com.squareup.retrofit2:converter-gson:' + rootProject.retrofitVersion
    implementation 'com.squareup.retrofit2:adapter-rxjava2:' + rootProject.retrofitVersion
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
    implementation 'com.google.code.gson:gson:2.8.2'
    //room
    implementation 'androidx.room:room-runtime:2.0.0-rc01'
    implementation 'androidx.room:room-rxjava2:2.0.0-rc01'
    kapt 'androidx.room:room-compiler:2.0.0-rc01'
    // roomigrant
    implementation 'com.github.MatrixDev.Roomigrant:RoomigrantLib:0.1.1'
    kapt 'com.github.MatrixDev.Roomigrant:RoomigrantCompiler:0.1.1'
    //image
    implementation 'com.github.bumptech.glide:glide:3.7.0'
    implementation 'jp.wasabeef:glide-transformations:2.0.1'
    implementation 'us.feras.mdv:markdownview:1.1.0'
    implementation 'org.jsoup:jsoup:1.11.1'
    implementation 'com.github.franmontiel:PersistentCookieJar:v1.0.1'
    ///////////unit test///////////////
    testImplementation 'org.mockito:mockito-core:2.15.0'
    testImplementation 'junit:junit:4.12'
    testImplementation 'com.github.fabioCollini.daggermock:daggermock:0.8.4'
    //////////ui test//////////////////
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs', module: 'jsr305'
    })
}

//https://github.com/google/dagger/issues/306
gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xmaxerrs" << "500" // or whatever number you want
    }
}