apply plugin: 'com.android.library'

android {
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
    }

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

}

dependencies {
    compileOnly project(':hiddenapi-stubs')
    implementation project(':xposed-bridge')
    compileOnly project(':dexmaker')
    api "androidx.annotation:annotation:1.1.0-rc01"
}


preBuild.doLast {
    def imlFile = file(project.name + ".iml")
    try {
        def parsedXml = (new groovy.util.XmlParser()).parse(imlFile)
        def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
        parsedXml.component[1].remove(jdkNode)
        def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
        new groovy.util.Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
        groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
    } catch (FileNotFoundException e) {
        // nop, iml not found
    }
}

afterEvaluate {

    tasks.withType(JavaCompile) {
        options.compilerArgs.add("-Xbootclasspath/p:${hiddenApiStubJarFilePath}")
    }

    task("copyCommonProperties", type: Copy) {
        from file("${projectDir}/template_override/")
        into file(templateRootPath)
    }
}