// NOTE:This file was generated from packages/generator-react-native-vector-icons/src/app/templates
// If you're contributing to react-native-vector-icons, make the change there, otherwise it'll be lost

def isNewArchitectureEnabled() {
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

def safeExtGet(prop, fallback) {
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: "com.android.library"
// AGP 9 ships built-in Kotlin support and registers the `kotlin` extension
// itself. Applying the Kotlin plugin on top of it fails configuration with
// "Cannot add extension with name 'kotlin'". Only apply it when nothing has
// registered that extension yet.
if (project.extensions.findByName('kotlin') == null) {
  apply plugin: "kotlin-android"
}

if (isNewArchitectureEnabled()) {
  apply plugin: "com.facebook.react"
}

android {
  namespace "com.reactnativevectoricons.material_design_icons"

  compileSdk safeExtGet('compileSdkVersion', 34)

  defaultConfig {
    minSdk safeExtGet('minSdkVersion', 24)
  }
}

dependencies {
  implementation "com.facebook.react:react-android"
}

if (isNewArchitectureEnabled()) {
  react {
    jsRootDir = file("../src/")
    libraryName = "VectorIconsMaterialDesignIcons"
    codegenJavaPackageName = "com.reactnativevectoricons.material_design_icons"
  }
}

android.sourceSets.main.assets.srcDirs += layout.buildDirectory.dir("intermediates/RNVI-material-design-icons").get().asFile

def copyFonts = tasks.register("copyFonts", Copy) {
  from "../fonts"
  include "*.ttf"

  into layout.buildDirectory.dir("intermediates/RNVI-material-design-icons/fonts")
  eachFile { println "(RNVI:material-design-icons) Copying font ${it.file}" }
}

preBuild.dependsOn(copyFonts)
