apply plugin: 'com.android.library'

android {
    compileSdkVersion project.hasProperty('compileSdkVersion') ? project.compileSdkVersion : 27
    buildToolsVersion project.hasProperty('buildToolsVersion') ? project.buildToolsVersion : "27.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
}

dependencies {
    implementation('com.rollbar:rollbar-android:1.7.1')
    implementation 'com.facebook.react:react-android:0.71.0'
    implementation 'com.google.code.gson:gson:2.9.0'

    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.mockito:mockito-core:3.8.0'
    testImplementation 'org.mockito:mockito-inline:3.8.0'
}

afterEvaluate {
    // Disable running tests automatically unless explicitly enabled
    tasks.matching { it.name.startsWith("test") }.configureEach {
        onlyIf { project.hasProperty("runTests") }
    }

    // Optionally ensure the build task itself doesn’t depend on tests
    def buildTask = tasks.findByName("build")
    if (buildTask != null) {
        // Filter out any "test*" dependencies safely
        buildTask.dependsOn = buildTask.dependsOn.findAll { dep ->
            !(dep instanceof String && dep.startsWith("test")) &&
            !(dep instanceof Task && dep.name.startsWith("test"))
        }
    }
}
