import io.gitlab.arturbosch.detekt.Detekt

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'com.yanzhenjie.andserver'
    id "io.gitlab.arturbosch.detekt"
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "com.youngfeng.android.assistant"
        minSdk 21
        targetSdk 29
        versionCode 31
        versionName "0.3.1"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

        debug {
            minifyEnabled false
            resValue("string", "PORT_NUMBER", "8081")
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }

    detekt {
        toolVersion = "1.19.0-RC1"

        buildUponDefaultConfig = false
        allRules = true
        autoCorrect = true
        config = files("${project.rootDir.absolutePath}/config/detekt.yml")
        debug = true

        source = files(
                "src/main/java"
        )

        reports {
            html {
                enabled = true
                destination  = file("build/reports/detekt/detekt.html")
            }
        }
    }

    dataBinding {
        enabled = true
    }
}

tasks.withType(Detekt).configureEach {
    jvmTarget = "1.8"
}

project.afterEvaluate {
    def detekt = tasks.getByName("detekt")
    tasks.getByName("preBuild").dependsOn(detekt)
}

dependencies {
    implementation 'androidx.core:core-ktx:1.8.0'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

    implementation 'com.yanzhenjie.andserver:api:2.1.10'
    kapt 'com.yanzhenjie.andserver:processor:2.1.10'
    implementation 'javax.activation:javax.activation-api:1.2.0'

    implementation 'com.google.code.gson:gson:2.9.0'
    detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.19.0-RC1")

    implementation 'org.java-websocket:Java-WebSocket:1.5.2'
    implementation "net.lingala.zip4j:zip4j:2.9.1"

    def room_version = "2.4.2"

    implementation "androidx.room:room-runtime:$room_version"
    kapt "androidx.room:room-compiler:$room_version"

    implementation 'commons-codec:commons-codec:1.15'

    implementation "androidx.activity:activity-ktx:1.4.0"

    implementation "org.greenrobot:eventbus:3.3.1"
    implementation 'com.github.bingoogolapple.BGAQRCode-Android:zxing:1.3.8'
    implementation 'pub.devrel:easypermissions:3.0.0'
    implementation 'com.jakewharton.timber:timber:5.0.1'

    debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'

    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'com.github.vestrel00:contacts-android:0.2.2'
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.6.21"
}