/*
 * 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
 *
 *      http://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.
 */

/**
 * This file was created using the `create_project.py` script located in the
 * `<AndroidX root>/development/project-creator` directory.
 *
 * Please use that script when creating a new project, rather than copying an existing project and
 * modifying its settings.
 */
import androidx.build.LibraryType
import androidx.glance.appwidget.layoutgenerator.gradle.LayoutGeneratorTask

plugins {
    id("AndroidXPlugin")
    id("org.jetbrains.kotlin.android")
    id("com.android.library")
    id("AndroidXComposePlugin")
    id("com.google.protobuf")
}

dependencies {
    api(project(":glance:glance"))
    api("androidx.annotation:annotation:1.8.1")
    api("androidx.compose.runtime:runtime:1.1.1")
    api("androidx.compose.ui:ui-graphics:1.1.1")
    api("androidx.compose.ui:ui-unit:1.1.1")
    api("androidx.collection:collection-ktx:1.4.3")

    implementation("androidx.core:core-ktx:1.7.0")
    implementation("androidx.datastore:datastore:1.0.0")
    implementation("androidx.datastore:datastore-core:1.0.0")
    implementation("androidx.datastore:datastore-preferences-core:1.0.0")
    implementation("androidx.datastore:datastore-preferences:1.0.0")
    implementation(project(":core:core-remoteviews"))
    implementation(project(":glance:glance-appwidget-proto"))
    implementation(libs.kotlinStdlib)

    testImplementation(libs.junit)
    testImplementation(libs.kotlinCoroutinesTest)
    testImplementation(libs.kotlinTest)
    testImplementation(libs.mockitoCore4)
    testImplementation(libs.mockitoKotlin4)
    testImplementation(libs.robolectric)
    testImplementation(libs.testCore)
    testImplementation(libs.testRules)
    testImplementation(libs.testRunner)
    testImplementation(libs.truth)
    testImplementation(libs.kotlinReflect)
    testImplementation("androidx.core:core-ktx:1.7.0")
    testImplementation("androidx.datastore:datastore-core:1.0.0")
    testImplementation("androidx.datastore:datastore-preferences-core:1.0.0")
    testImplementation("androidx.datastore:datastore-preferences:1.0.0")

    androidTestImplementation(project(":test:screenshot:screenshot"))
    androidTestImplementation(project(":glance:glance-material3"))
    androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0")
    androidTestImplementation("androidx.room:room-runtime:2.4.3")
    androidTestImplementation("androidx.core:core-ktx:1.7.0")
    androidTestImplementation("androidx.work:work-testing:2.7.1")
    androidTestImplementation(libs.espressoCore)
    androidTestImplementation(libs.espressoIdlingResource)
    androidTestImplementation(libs.kotlinCoroutinesTest)
    androidTestImplementation(libs.kotlinTest)
    androidTestImplementation(libs.testCore)
    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testExtJunitKtx)
    androidTestImplementation(libs.testRules)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.truth)
    androidTestImplementation(libs.kotlinReflect)
}

android {
    // Use Robolectric 4.+
    testOptions.unitTests.includeAndroidResources = true
    resourcePrefix "glance_"
    buildTypes {
        debug {
            pseudoLocalesEnabled = true
        }
    }
    namespace = "androidx.glance.appwidget"

    buildTypes.configureEach {
        consumerProguardFiles("proguard-rules.pro")
    }
    // TODO(b/313699418): need to update compose.runtime version to 1.6.0+
    experimentalProperties["android.lint.useK2Uast"] = false

    compileSdk = 35
}

androidx {
    name = "Glance For App Widgets"
    type = LibraryType.PUBLISHED_LIBRARY_ONLY_USED_BY_KOTLIN_CONSUMERS
    inceptionYear = "2021"
    description = "Glance-appwidgets allows developers to build layouts for Android AppWidgets " +
            "using a Jetpack Compose-style API."
    legacyDisableKotlinStrictApiMode = true
    metalavaK2UastEnabled = false
    samples(project(":glance:glance-appwidget:glance-appwidget-samples"))
    addGoldenImageAssets()
}

LayoutGeneratorTask.registerLayoutGenerator(
        project,
        /* containerLayoutDirectory= */ file("src/main/layoutTemplates"),
        /* childLayoutDirectory= */ file("src/main/res/layout")
)
