plugins {
  id "com.android.library"
}

def coreProj
if (findProject(':core')) {
  coreProj = project(':core')
} else if (findProject(':sentiance-react-native_core')) {
  // Starting from RN 0.61, the @ sign is stripped from project names
  coreProj = project(':sentiance-react-native_core')
} else if (findProject(':@sentiance-react-native_core')) {
  // On RN 0.60, the @ sign is not stripped from project names
  coreProj = project(':@sentiance-react-native_core')
} else {
  throw new GradleException('Could not find the @sentiance-react-native/core package, have you installed it?')
}

def crashDetectionProj
if (findProject(':crash-detection')) {
  crashDetectionProj = project(':crash-detection')
} else if (findProject(':sentiance-react-native_crash-detection')) {
  // Starting from RN 0.61, the @ sign is stripped from project names
  crashDetectionProj = project(':sentiance-react-native_crash-detection')
} else if (findProject(':@sentiance-react-native_crash-detection')) {
  // On RN 0.60, the @ sign is not stripped from project names
  crashDetectionProj = project(':@sentiance-react-native_crash-detection')
} else {
  throw new GradleException('Could not find the @sentiance-react-native/crash-detection package, have you installed it?')
}

android {
  namespace "com.sentiance.react.bridge.legacy"

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

apply from: "$coreProj.projectDir/package-json-reader.gradle"

def corePackageJson = PackageJson.of(coreProj)
applyAndroidVersionsFrom(corePackageJson)

dependencies {
  implementation crashDetectionProj
}

applyReactNativeDependency()
