/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import com.facebook.fresco.buildsrc.Deps
import com.facebook.fresco.buildsrc.GradleDeps
import com.facebook.fresco.buildsrc.TestDeps

apply plugin: 'com.android.library'

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(11))
    }
}

dependencies {
    compileOnly Deps.inferAnnotation
    compileOnly Deps.jsr305
    compileOnly Deps.javaxAnnotation
    compileOnly Deps.AndroidX.androidxAnnotation

    implementation project(':imagepipeline')
    implementation project(':fbcore')
    implementation Deps.SoLoader.soloader

    testImplementation TestDeps.junit
    testImplementation TestDeps.assertjCore
    testImplementation TestDeps.mockitoCore
    testImplementation(TestDeps.Powermock.apiMockito) {
        exclude group: 'org.mockito', module: 'mockito-all'
    }
    testImplementation TestDeps.Powermock.moduleJunit4
    testImplementation TestDeps.Powermock.moduleJunit4Rule
    testImplementation TestDeps.Powermock.classloadingXstream
    testImplementation(TestDeps.robolectric) {
        exclude group: 'commons-logging', module: 'commons-logging'
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'
    }
    testImplementation project(':imagepipeline-base-test')
    testImplementation project(':imagepipeline-test')
}


android {
    ndkVersion GradleDeps.Native.version

    def ndkLibs = [
            ['bitmaps', []],
            ['imagepipeline', []],
            ['memchunk', []]]

    buildToolsVersion FrescoConfig.buildToolsVersion
    compileSdkVersion FrescoConfig.compileSdkVersion

    namespace "com.facebook.imagepipeline.nativecode"

    defaultConfig {
        minSdkVersion FrescoConfig.minSdkVersion
        targetSdkVersion FrescoConfig.targetSdkVersion
    }

    sourceSets {
        main {
            jni.srcDirs = []
            jniLibs.srcDirs = ndkLibs.collect { "$buildDir/${it[0]}" }
        }
        test {
            java {
                exclude '**/LocalVideoThumbnailProducerTest.java'
                exclude '**/DecodeProducerTest.java'
                exclude '**/ProgressiveJpegParserTest.java'
                exclude '**/AnimatedImageFactoryTest.java'

            }
            resources {
                exclude '**/BUCK'
            }
        }
    }
    ndkLibs.each { lib -> makeNdkTasks lib[0], lib[1] }
    preBuild.dependsOn(
        "ndk_build_bitmaps",
        "ndk_build_imagepipeline",
        "ndk_build_memchunk"
    )
}

apply plugin: "com.vanniktech.maven.publish"
