plugins {
    id 'com.android.library'
    id("org.jetbrains.dokka") version "1.5.0"
}
apply plugin: 'kotlin-android'

android.buildFeatures.buildConfig true

android {
    compileSdkVersion 34
    buildToolsVersion "34.0.0"

    kotlinOptions {
        jvmTarget = "17"
    }

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 34
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
        // The hack below is because VERSION_NAME has been removed from BuildConfig as of Gradle Plugin 4.1
        def addConstant = {constantName, constantValue ->
            manifestPlaceholders += [ (constantName):constantValue]
            buildConfigField "String", "${constantName}", "\"${constantValue}\""
        }
        addConstant("VERSION_NAME", version)
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    packagingOptions {
        exclude 'LICENSE.txt'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE'
    }

    testOptions {
        execution 'ANDROIDX_TEST_ORCHESTRATOR'
        animationsDisabled true
        unitTests {
            includeAndroidResources = true
        }
    }
    lintOptions {
        abortOnError false
    }

    namespace 'org.altbeacon.beacon'
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.2.0' // 1.6.1 requires targeting android SDK 33
    testImplementation 'junit:junit:4.13.2'
    testImplementation 'org.hamcrest:hamcrest:2.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

    testImplementation 'junit:junit:4.13.2'

    testImplementation 'org.robolectric:robolectric:4.11.1'
    testImplementation 'com.google.android:android-test:4.1.1.4'
    //testImplementation 'com.squareup:fest-android:1.0.8@aar'
    testImplementation 'org.mockito:mockito-core:2.23.4'

    androidTestUtil 'androidx.test:orchestrator:1.4.2'

    androidTestImplementation 'androidx.test:rules:1.5.0'
    androidTestImplementation 'org.apache.commons:commons-math3:3.6.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation "androidx.core:core-ktx:1.12.0"
    implementation "androidx.lifecycle:lifecycle-process:2.6.2"

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    dokkaHtmlPlugin("org.jetbrains.dokka:kotlin-as-java-plugin:1.5.0")
}

ext {
    PUBLISH_GROUP_ID = 'org.altbeacon'
    PUBLISH_VERSION = version
    PUBLISH_ARTIFACT_ID = 'android-beacon-library'
}

repositories {
    mavenCentral()
}
if (getGradle().getStartParameter().getTaskRequests().toString().contains("release") ||
        getGradle().getStartParameter().getTaskRequests().toString().contains("mavenPublish") ||
        getGradle().getStartParameter().getTaskRequests().toString().contains("closeAndReleaseRepository")) {
    apply from: "../gradle/publish-mavencentral.gradle"
}

