plugins {
    id 'org.jetbrains.kotlin.plugin.serialization' version '1.6.10'
}

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

apply plugin: 'com.google.protobuf'
apply plugin: 'com.klaxit.hiddensecrets'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "tw.gov.cdc.exposurenotifications"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 65
        versionName "2.2.0"
        ndk {
            debugSymbolLevel 'FULL'
        }
        resConfigs "zh-rTW", "zh-rCN", "in", "th", "tl", "vi", "ms", "my"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

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

    sourceSets {
        main {
            java {
                srcDirs 'src/main/java', 'src/main/java/activity'
            }
            proto {
                srcDirs 'src/main/java/tw/gov/cdc/exposurenotifications/proto'
            }
        }
    }

// To inline the bytecode built with JVM target 1.8 into
// bytecode that is being built with JVM target 1.6. (e.g. navArgs)

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = "1.8"
    }

    // Enable NDK build
    externalNativeBuild {
        cmake {
            path "src/main/cpp/CMakeLists.txt"
        }
    }

    lintOptions {
        abortOnError false
    }
}

repositories {
    maven { url "https://jitpack.io" }
}

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.11.4'
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    option "lite"
                }
            }
        }
    }
}

dependencies {
    apply plugin: 'kotlin-kapt'

    implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation "androidx.fragment:fragment-ktx:1.3.0"
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.core:core-ktx:1.6.0'

    // Google Service
    implementation 'com.google.android.gms:play-services-base:17.6.0'
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.4.1"

    // Barcode Scanning (dynamically downloaded model in Google Play Services)
    implementation 'com.google.android.gms:play-services-mlkit-barcode-scanning:16.2.0'

    // CameraX core library using the camera2 implementation
    def camerax_version = "1.0.0"
    implementation "androidx.camera:camera-camera2:${camerax_version}"
    implementation "androidx.camera:camera-lifecycle:${camerax_version}"
    implementation "androidx.camera:camera-view:1.0.0-alpha26"

    // Lifecycle
    def lifecycle_version = "2.3.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"

    // In-app updates
    implementation 'com.google.android.play:core:1.10.0'
    implementation 'com.google.android.play:core-ktx:1.8.1'

    // WorkManager
    implementation "androidx.work:work-runtime-ktx:2.5.0"

    // protobuf //DiagnosisKeyFileHelper
    implementation 'com.google.protobuf:protobuf-javalite:3.14.0'

    // IOUtils //DiagnosisKeyFileHelper
    implementation 'commons-io:commons-io:2.6'

    // BaseEncoding //DiagnosisKeyFileHelper
    implementation 'com.google.guava:guava:30.1.1-android'

    // DiagnosisKey
//    annotationProcessor 'com.google.auto.value:auto-value:1.7.3'
//    implementation 'com.google.auto.value:auto-value-annotations:1.7.3'
    implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'

    // UI components
    implementation 'com.airbnb.android:lottie:5.0.3'
    
    // zxing
    implementation 'com.google.zxing:core:3.3.2'

    // networking
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'

    // Logger
    implementation 'io.github.microutils:kotlin-logging:1.7.4'
    implementation 'com.github.tony19:logback-android:2.0.0'

    // COSE
    implementation 'org.bouncycastle:bcpkix-jdk15to18:1.69'
    implementation 'com.augustcellars.cose:cose-java:1.1.0'

    // Json
    implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2'
}
