apply plugin: 'com.android.application'
apply plugin: "de.mannodermaus.android-junit5"
apply plugin: 'jacoco'

def junit_version = '6.0.0'

System.setProperty("line.separator", "\n")
Properties versionProps = new Properties()
def versionPropsFile = file('version.properties')
if (versionPropsFile.exists()) {
    versionProps.load(new FileInputStream(versionPropsFile))
}

int vcode = Integer.parseInt((versionProps['VERSION_CODE'] == null || versionProps['VERSION_CODE'].startsWith('$')) ? String.valueOf((int) ((System.currentTimeMillis() / 1000 / 60) - 26_797_800)) : versionProps['VERSION_CODE'])
String vname = (versionProps['VERSION_NAME'] == null || versionProps['VERSION_NAME'].startsWith('$')) ? '3.5.0-dev' : versionProps['VERSION_NAME']

jacoco {
    toolVersion = "0.8.12"
}

tasks.register("unitTestCoverageReport", JacocoReport) {
    group = "Coverage"
    dependsOn tasks.testDebugUnitTest
    reports {
        html.required = true
        xml.required = true
    }
    executionData.from = layout.buildDirectory.dir("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
    classDirectories.from = layout.buildDirectory.dir("intermediates/javac/debug/compileDebugJavaWithJavac/classes")
    sourceDirectories.from = layout.projectDirectory.dir("src/main/java")
}

android {
    compileSdkVersion(36)
    defaultConfig {
        applicationId "com.github.frimtec.android.securesmsproxy"
        minSdkVersion 24
        targetSdkVersion 36
        versionCode vcode
        versionName vname
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        debug {
            enableUnitTestCoverage true
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    testOptions {
        unitTests.returnDefaultValues = true
    }
    namespace 'com.github.frimtec.android.securesmsproxy'
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
    implementation 'androidx.activity:activity:1.11.0'
    implementation 'com.google.android.material:material:1.12.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.googlecode.libphonenumber:libphonenumber:9.0.15'
    implementation project(path: ':securesmsproxyapi')
    testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
    testImplementation "org.junit.jupiter:junit-jupiter-params:$junit_version"
    testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"
    testImplementation "org.assertj:assertj-core:3.27.6"
    testImplementation "org.mockito:mockito-core:5.20.0"
    testImplementation 'org.json:json:20250517'
    androidTestImplementation 'androidx.test:runner:1.7.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
}
