pluginManagement {
  // Linked manually to used version from our RN fork
  includeBuild(new File(rootDir, "../../../react-native-lab/react-native/packages/gradle-plugin").toString())

  def expoPluginsPath = new File(
    providers.exec {
      workingDir(rootDir)
      commandLine("node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })")
    }.standardOutput.asText.get().trim(),
    "../android/expo-gradle-plugin"
  ).absolutePath
  includeBuild(expoPluginsPath)

  repositories {
    mavenCentral()
    gradlePluginPortal()
    mavenLocal()
    google()
  }
}

plugins {
  id("com.facebook.react.settings")
  id("expo-autolinking-settings")
}

extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
  ex.autolinkLibrariesFromCommand(expoAutolinking.rnConfigCommand)
}

expoAutolinking.searchPaths = [
  '../../../packages'
]
expoAutolinking.exclude = [
  'expo-module-template',
  'expo-module-template-local',
  'react-native-reanimated',
  'expo-dev-menu-interface',
  'expo-dev-menu',
  'expo-dev-launcher',
  'expo-dev-client',
  'expo-maps',
  'expo-network-addons',
  'expo-splash-screen',
  'expo-blob',
  '@expo/ui',
  'expo-mesh-gradient',
  '@expo/app-integrity'
]

expoAutolinking.useExpoModules()

include ':app'

apply from: new File(rootDir, "versioning_linking.gradle")

// Linked manually to used version from our RN fork
includeBuild(new File(rootDir, "../../../react-native-lab/react-native/packages/gradle-plugin").toString())

include ':expoview'
include ':tools'

include(":packages")
project(":packages").projectDir = file("$rootDir/../../../react-native-lab/react-native/packages") // Gradle 9 require us to include this
include ':packages:react-native:ReactAndroid'
project(':packages:react-native:ReactAndroid').projectDir = new File(rootDir, '../../../react-native-lab/react-native/packages/react-native/ReactAndroid')
dependencyResolutionManagement {
  versionCatalogs {
    defaultLibrariesExtensionName = "expoLibs"
    libs {
      from(files("../../../react-native-lab/react-native/packages/react-native/gradle/libs.versions.toml"))
    }
  }
}
include ':packages:react-native:ReactAndroid:hermes-engine'
project(':packages:react-native:ReactAndroid:hermes-engine').projectDir = new File(rootDir, '../../../react-native-lab/react-native/packages/react-native/ReactAndroid/hermes-engine')
include ':expo-modules-test-core'
project(':expo-modules-test-core').projectDir = new File(rootDir, '../../../packages/expo-modules-test-core/android')

[
    // ADD_NEW_SUPPORTED_ABIS_HERE
].forEach({ abiVariant ->
  include ":expoview-$abiVariant"
  project(":expoview-$abiVariant").projectDir = new File(rootDir, "versioned-abis/expoview-$abiVariant")
})
