plugins {
    id 'com.android.library'
    id 'kotlin-android'
    id 'maven-publish'
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            groupId = 'com.github.fingerprintjs'
            artifactId = "aev"
            version = '1.1.0'
            artifact("$buildDir/outputs/aar/AEV-1.1.0-release.aar")
        }
    }
}

android {
    compileSdkVersion 33

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 33
        versionCode Integer.parseInt(project.VERSION_CODE)
        versionName project.VERSION_NAME
    }

    buildTypes {
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField 'boolean', 'DEBUG_CONST', 'true'
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            buildConfigField 'boolean', 'DEBUG_CONST', 'false'
        }
    }

    libraryVariants.all { variant ->
        variant.outputs.all { output ->
            if (outputFile != null && outputFileName.endsWith('.aar')) {
                outputFileName = "AEV-${defaultConfig.versionName}-${variant.name}.aar"
            }
        }
    }

    kotlinOptions {
        freeCompilerArgs += "-Xopt-in=kotlin.contracts.ExperimentalContracts"
    }
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
    if (!it.name.contains("Test")) {
        kotlinOptions.freeCompilerArgs += "-Xexplicit-api=warning"
    }
}

dependencies {
    testImplementation 'junit:junit:4.+'
    implementation "com.github.fingerprintjs:fingerprint-android:2.0.0"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    testImplementation("com.squareup.okhttp3:mockwebserver:4.9.3")
    testImplementation 'com.squareup.okhttp3:okhttp-tls:4.9.3'
    testImplementation 'org.json:json:20210307'
}
