plugins {
    id "net.ltgt.errorprone" version "0.0.13"
}

new RoboJavaModulePlugin(
        deploy: true
).apply(project)

apply plugin: ShadowsPlugin

shadows {
    packageName "org.robolectric"
}

configurations {
    jni
}

task copyNatives(type: Copy) {
    outputs.dir file("${buildDir}/resources/main")

    project.afterEvaluate {
        configurations.jni.files.each { File file ->
            def nativeJarMatch = file.name =~ /lib.*-natives-(.*)\.jar/
            if (nativeJarMatch) {
                inputs.file file

                def platformName = nativeJarMatch[0][1]
                from(zipTree(file)) { rename { f -> "$platformName/$f" } }
            }

        }
    }

    into project.file("$buildDir/resources/main")
}

jar {
    dependsOn copyNatives
}

dependencies {
    // Project dependencies
    compile project(":annotations")
    compile project(":resources")
    compile project(":utils")

    // Compile dependencies
    compileOnly "com.google.code.findbugs:jsr305:3.0.1"
    compile "com.almworks.sqlite4java:sqlite4java:0.282"
    compileOnly(AndroidSdk.MAX_SDK.coordinates) { force = true }
    compile "com.ibm.icu:icu4j:53.1"
    compile "com.google.android.apps.common.testing.accessibility.framework:accessibility-test-framework:2.1"

    jni "com.github.axet.litedb:libsqlite:0.282-3:natives-mac-x86_64"
    jni "com.github.axet.litedb:libsqlite:0.282-3:natives-linux-x86"
    jni "com.github.axet.litedb:libsqlite:0.282-3:natives-linux-x86_64"
    jni "com.github.axet.litedb:libsqlite:0.282-3:natives-windows-x86"
    jni "com.github.axet.litedb:libsqlite:0.282-3:natives-windows-x86_64"
}