/*
 * Copyright 2021 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
 *
 *     https://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.
 */
plugins {
    alias(libs.plugins.android.application)
    alias(libs.plugins.kotlin.android)
    alias libs.plugins.roborazzi
    alias(libs.plugins.ksp)
    alias(libs.plugins.hilt)
    alias(libs.plugins.compose)
}

android {
    compileSdk 35

    namespace "com.example.jetcaster"

    defaultConfig {
        applicationId "com.example.jetcaster"
        minSdk 26
        targetSdk 34
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            signingConfig signingConfigs.debug
            proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
        coreLibraryDesugaringEnabled true
    }
    testOptions {
        unitTests {
            includeAndroidResources true
        }
    }
    
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_17.majorVersion
        freeCompilerArgs = freeCompilerArgs + "-opt-in=kotlin.RequiresOptIn"
        freeCompilerArgs = freeCompilerArgs + "-opt-in=com.google.android.horologist.annotations.ExperimentalHorologistApi"
    }
    buildFeatures {
        compose true
    }
    
    packagingOptions {
        resources {
            excludes += "/META-INF/{AL2.0,LGPL2.1}"
            excludes += "rome-utils-" + libs.rometools.rome.get().version + ".jar"
        }
    }

    composeCompiler {
        reportsDestination = layout.buildDirectory.dir("compose_compiler")
        metricsDestination = layout.buildDirectory.dir("compose_compiler")
        stabilityConfigurationFile = rootProject.layout.projectDirectory.file("stability_config.conf")
    }
}

dependencies {

    def composeBom = platform(libs.androidx.compose.bom)

    // General compose dependencies
    implementation composeBom
    implementation libs.androidx.activity.compose
    implementation libs.androidx.core.splashscreen

    // Compose for Wear OS Dependencies
    // NOTE: DO NOT INCLUDE a dependency on androidx.compose.material:material.
    // androidx.wear.compose:compose-material is designed as a replacement not an addition to
    // androidx.compose.material:material. If there are features from that you feel are missing from
    // androidx.wear.compose:compose-material please raise a bug to let us know:
    // https://issuetracker.google.com/issues/new?component=1077552&template=1598429&pli=1
    implementation libs.androidx.wear.compose.material

    // For using the phone Typography
    implementation libs.androidx.compose.material3

    implementation(libs.kotlinx.collections.immutable)

    // Foundation is additive, so you can use the mobile version in your Wear OS app.
    implementation libs.androidx.wear.compose.foundation

    implementation(libs.androidx.media3.exoplayer)
    implementation(libs.androidx.media3.ui.compose)
    implementation(libs.androidx.media3.session)
    implementation libs.androidx.media3.common.ktx

    // Horologist for correct Compose layout
    implementation libs.horologist.compose.layout

    //Horologist Media toolkit
    implementation libs.horologist.media.ui
    implementation libs.horologist.media.uimaterial3
    implementation libs.horologist.media.ui.model
    implementation libs.horologist.audio.ui
    implementation libs.horologist.audio.uimaterial3
    implementation libs.horologist.audio.ui.model
    implementation libs.horologist.media.data
    implementation libs.horologist.images.coil

    // Dependency injection
    implementation(libs.androidx.hilt.navigation.compose)
    implementation(libs.hilt.android)
    ksp(libs.hilt.compiler)

    // Preview Tooling
    implementation libs.androidx.compose.ui.tooling.preview
    implementation(libs.androidx.compose.ui.tooling)
    implementation libs.androidx.wear.compose.ui.tooling

    // If you are using Compose Navigation, use the Wear OS version (NOT the
    // androidx.navigation:navigation-compose version), that is, uncomment the line below.
    implementation libs.androidx.wear.compose.navigation

    implementation libs.androidx.compose.ui.test.manifest

    implementation(libs.coil.kt.compose)

    coreLibraryDesugaring(libs.core.jdk.desugaring)

    implementation projects.core.data
    implementation projects.core.designsystem
    implementation projects.core.domain
    implementation projects.core.domainTesting

    // Testing
    testImplementation libs.androidx.compose.ui.test.junit4
    testImplementation libs.junit
    testImplementation libs.robolectric
    testImplementation libs.roborazzi
    testImplementation libs.roborazzi.compose
    testImplementation libs.roborazzi.rule
    testImplementation(libs.horologist.roboscreenshots)

    androidTestImplementation libs.androidx.test.ext.junit
    androidTestImplementation libs.androidx.test.espresso.core
    androidTestImplementation libs.androidx.compose.ui.test.junit4
    androidTestImplementation composeBom

    debugImplementation(libs.androidx.compose.ui.tooling)
    debugImplementation libs.androidx.compose.ui.test.manifest
    debugImplementation composeBom
}
