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

buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.1'
    }
}

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

apply plugin: 'com.android.library'

android {
    compileSdkVersion 33

    if (project.android.hasProperty('namespace')) {
        namespace 'io.flutter.plugins.googlemobileads'
    }

    defaultConfig {
        minSdkVersion 21
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    dependencies {
        api 'com.google.android.gms:play-services-ads:23.0.0'
        implementation 'com.google.android.ump:user-messaging-platform:2.2.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
        implementation 'androidx.lifecycle:lifecycle-process:2.6.2'
        implementation 'com.google.errorprone:error_prone_annotations:2.16'
        testImplementation 'junit:junit:4.13.2'
        testImplementation 'org.hamcrest:hamcrest:2.2'
        testImplementation 'org.mockito:mockito-inline:5.2.0'
        testImplementation 'org.robolectric:robolectric:4.10.3'
        testImplementation 'androidx.test:core:1.5.0'
    }
    testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }
}

afterEvaluate {
    def containsEmbeddingDependencies = false
    for (def configuration : configurations.all) {
        for (def dependency : configuration.dependencies) {
            if (dependency.group == 'io.flutter' &&
                    dependency.name.startsWith('flutter_embedding') &&
                    dependency.isTransitive()) {
                containsEmbeddingDependencies = true
                break
            }
        }
    }
    if (!containsEmbeddingDependencies) {
        android {
            dependencies {
                def lifecycle_version = "1.1.1"
                compileOnly "android.arch.lifecycle:runtime:$lifecycle_version"
                compileOnly "android.arch.lifecycle:common:$lifecycle_version"
                compileOnly "android.arch.lifecycle:common-java8:$lifecycle_version"
            }
        }
    }
}
