/**
 * 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

plugins {
    id("AndroidXPlugin")
    id("com.android.library")
}

ext {
    fontDir = project(":noto-emoji-compat-font").projectDir
}

android {
    sourceSets {
        main {
            assets.srcDirs new File(fontDir, "font").getAbsolutePath()
            resources {
                srcDirs += [fontDir.getAbsolutePath()]
                includes += ["LICENSE_UNICODE", "LICENSE_OFL"]
            }
        }

        androidTest {
            assets {
                srcDirs = [new File(fontDir, "supported-emojis").getAbsolutePath()]
            }
        }
    }
    namespace = "androidx.emoji2.bundled"

}

dependencies {
    api(libs.jspecify)
    api(project(":emoji2:emoji2"))

    androidTestImplementation(libs.testExtJunit)
    androidTestImplementation(libs.testCore)
    androidTestImplementation(libs.testRunner)
    androidTestImplementation(libs.testRules)
    androidTestImplementation(libs.espressoCore)
    androidTestImplementation(libs.mockitoCore)
    androidTestImplementation(libs.dexmakerMockito)
    androidTestImplementation(project(":internal-testutils-runtime"))

    // view tests that use font are in this module as well; for licensing reasons
    androidTestImplementation(project(":emoji2:emoji2-views"))
}

androidx {
    name = "Emoji2 Bundled"
    type = LibraryType.PUBLISHED_LIBRARY
    inceptionYear = "2017"
    description = "Library bundled with assets to enable emoji compatibility in Kitkat and newer " +
            "devices to avoid the empty emoji characters."

    extraLicense {
        name = "SIL Open Font License, Version 1.1"
        url = "http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web"
    }

    extraLicense {
        name = "Unicode, Inc. License"
        url = "http://www.unicode.org/copyright.html#License"
    }
}
