group 'io.flutter.plugins.firebasemessaging'
version '1.0-SNAPSHOT'

apply plugin: 'com.android.library'
apply from: file("local-config.gradle")

androidGradlePluginVersion = project.ext.androidGradlePluginVersion

buildscript {
  repositories {
    google()
    mavenCentral()
  }
}

rootProject.allprojects {
  repositories {
    google()
    mavenCentral()
  }
}

def firebaseCoreProject = findProject(':firebase_core')
if (firebaseCoreProject == null) {
  throw new GradleException('Could not find the firebase_core FlutterFire plugin, have you added it as a dependency in your pubspec?')
} else if (!firebaseCoreProject.properties['FirebaseSDKVersion']) {
  throw new GradleException('A newer version of the firebase_core FlutterFire plugin is required, please update your firebase_core pubspec dependency.')
}

def getRootProjectExtOrCoreProperty(name, firebaseCoreProject) {
  if (!rootProject.ext.has('FlutterFire')) return firebaseCoreProject.properties[name]
  if (!rootProject.ext.get('FlutterFire')[name]) return firebaseCoreProject.properties[name]
  return rootProject.ext.get('FlutterFire').get(name)
}

android {
  // Conditional for compatibility with AGP <4.2.
  if (project.android.hasProperty("namespace")) {
    namespace 'io.flutter.plugins.firebase.messaging'
  }

  compileSdkVersion project.ext.compileSdk

  defaultConfig {
      minSdkVersion project.ext.minSdk
      testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  }

  compileOptions {
      sourceCompatibility project.ext.javaVersion
      targetCompatibility project.ext.javaVersion
  }

  buildFeatures {
    buildConfig = true
  }

  lintOptions {
    disable 'InvalidPackage'
  }

  dependencies {
    api firebaseCoreProject
    implementation platform("com.google.firebase:firebase-bom:${getRootProjectExtOrCoreProperty("FirebaseSDKVersion", firebaseCoreProject)}")
    implementation 'com.google.firebase:firebase-messaging'
    implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
    implementation 'androidx.annotation:annotation:1.7.1'
  }
}

apply from: file("./user-agent.gradle")
