import groovy.xml.XmlUtil

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "org.jlleitschuh.gradle.ktlint" version "9.4.0"
}

def gitDescribe = { ->
    def stdout = new ByteArrayOutputStream()
    exec {
        commandLine 'git', 'describe', '--always', '--tags', '--dirty=-dirty'
        standardOutput = stdout
    }
    return stdout.toString().trim()
}

android {

    compileSdkVersion 30
    buildToolsVersion '30.0.2'

    defaultConfig {
        minSdkVersion 29 // leave at 29 for robolectric tests
        targetSdkVersion 30
        versionNameSuffix "-$gitDescribe"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArguments disableAnalytics: 'true'
    }

    buildTypes {
        release {
            minifyEnabled false
        }
    }

    lintOptions {
        disable "CheckedExceptions"
        abortOnError true
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }
    testOptions {
        unitTests.all {
            useJUnitPlatform()
            testLogging {
                events "passed", "skipped", "failed"
            }
        }
        unitTests {
            includeAndroidResources = true
        }
    }

    sourceSets {
        test {
            java.srcDirs += "$projectDir/src/sharedTest/java"
        }
        androidTest {
            java.srcDirs += "$projectDir/src/sharedTest/java"
        }
    }

    signingConfigs {
        aosp {
            // Generated from the AOSP platform key:
            // https://android.googlesource.com/platform/build/+/refs/tags/android-11.0.0_r29/target/product/security/platform.pk8
            keyAlias "platform"
            keyPassword "platform"
            storeFile file("platform.jks")
            storePassword "platform"
        }
    }

    buildTypes.release.signingConfig = signingConfigs.aosp
    buildTypes.debug.signingConfig = signingConfigs.aosp
}

apply from: '../gradle/dependencies.gradle'

ktlint {
    version = "0.36.0" // https://github.com/pinterest/ktlint/issues/764
    android = true
    enableExperimentalRules = false
    verbose = true
    disabledRules = [
            "import-ordering",
            "no-blank-line-before-rbrace",
    ]
}

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        if (JavaVersion.current() >= JavaVersion.VERSION_1_9) {
            options.compilerArgs.addAll(['--release', '8'])
        }
        options.compilerArgs.add('-Xbootclasspath/p:app/libs/android.jar:app/libs/libcore.jar')
    }
}

// http://www.31mins.com/android-studio-build-system-application/
preBuild.doLast {
    def imlFile = file(project.name + ".iml")

    try {
        def parsedXml = (new XmlParser()).parse(imlFile)
        def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
        parsedXml.component[1].remove(jdkNode)

        def apiString = android.compileSdkVersion.substring("android-".length())
        def sdkString = "Android API " + apiString + " Platform"
        //noinspection GroovyResultOfObjectAllocationIgnored // the note gets inserted
        new Node(parsedXml.component[1], 'orderEntry', [
                'type'   : 'jdk',
                'jdkName': sdkString,
                'jdkType': 'Android SDK'
        ])
        XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))

    } catch (NullPointerException | FileNotFoundException ex) {
        ex.printStackTrace()
    }
}

configurations {
    all {
        resolutionStrategy {
            failOnNonReproducibleResolution()
        }
    }
}
