group 'io.flutter.plugins.googlemobileads'
version '8.0.0'

buildscript {
    ext {
        agp_version = '8.13.1'
    }
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:$agp_version"
    }
}

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

apply plugin: 'com.android.library'

android {
    compileSdk 36

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

    defaultConfig {
        minSdk 24
    }
    lintOptions {
        disable 'InvalidPackage'
    }
    dependencies {
        api 'com.google.android.gms:play-services-ads:25.1.0'
        implementation 'com.google.android.ump:user-messaging-platform:4.0.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
        implementation 'androidx.lifecycle:lifecycle-process:2.10.0'
        implementation 'com.google.errorprone:error_prone_annotations:2.48.0'
        testImplementation 'junit:junit:4.13.2'
        testImplementation 'org.hamcrest:hamcrest:3.0'
        testImplementation 'org.mockito:mockito-core:5.23.0'
        testImplementation 'org.robolectric:robolectric:4.16.1'
        testImplementation 'androidx.test:core:1.7.0'
    }
    testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }
}

afterEvaluate {
    def containsEmbeddingDependencies = configurations.any { configuration ->
        configuration.dependencies.any { dependency ->
            dependency.group == 'io.flutter' &&
                    dependency.name.startsWith('flutter_embedding') &&
                    (dependency instanceof ModuleDependency && dependency.isTransitive())
        }
    }
    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"
            }
        }
    }
}
