plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
    id "com.google.dagger.hilt.android"
    id 'kotlinx-serialization'
    id "kotlin-kapt"
    id 'com.google.protobuf' version '0.9.4'
}

android {
    namespace 'be.re.writand'
    compileSdk 34

    defaultConfig {
        applicationId "be.re.writand"
        minSdk 26
        targetSdk 34
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    kotlinOptions {
        jvmTarget = '17'
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.5.0'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
    testOptions {
        unitTests.all {
            useJUnitPlatform()
        }
        unitTests.includeAndroidResources = true
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    implementation 'androidx.core:core-ktx:1.13.1'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.3'
    implementation 'androidx.activity:activity-compose:1.9.0'
    implementation "androidx.compose.ui:ui:$compose_ui_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
    implementation 'androidx.compose.material:material:1.6.8'
    implementation 'androidx.test:core-ktx:1.6.1'
    implementation 'com.google.ar:core:1.44.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    // Testing
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_ui_version"
    testImplementation "junit:junit:4.13.2"
    testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.1"

    // Mockito testing
    testImplementation "org.mockito.kotlin:mockito-kotlin:3.2.0"
    testImplementation "org.robolectric:robolectric:4.4"
    testImplementation "androidx.test.ext:junit-ktx:1.1.5"
    testImplementation 'org.powermock:powermock-api-mockito:1.4.12'
    testImplementation 'org.powermock:powermock-module-junit4:1.6.2'

    testImplementation "org.mockito:mockito-core:4.2.0"
    testImplementation "org.mockito:mockito-inline:4.1.0"
    testImplementation "org.mockito:mockito-android:4.1.0"

    // Hilt
    implementation "com.google.dagger:hilt-android:2.48"
    kapt "com.google.dagger:hilt-compiler:2.48"

    // Room
    implementation 'androidx.room:room-runtime:2.6.1'
    annotationProcessor 'androidx.room:room-compiler:2.6.1'
    implementation 'androidx.room:room-ktx:2.6.1'

    // Proto DataStore
    implementation 'androidx.datastore:datastore:1.1.1'
    implementation 'com.google.protobuf:protobuf-javalite:3.21.7'

    debugImplementation "androidx.compose.ui:ui-tooling:$compose_ui_version"
    debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_ui_version"
}

kapt {
    correctErrorTypes true
}

protobuf {
    protoc {
        artifact = "com.google.protobuf:protoc:3.21.7"
    }
// Generates the java Protobuf-lite code for the Protobufs in this project.
// see https://github.com/google/protobuf-gradle-plugin#customizing-protobuf-compilation
// for more information.
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    option 'lite'
                }
            }
        }
    }
}