// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        mavenCentral()
        maven { url "https://jcenter.bintray.com" }
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.0-alpha14'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32"
    }
}

// sync from https://github.com/LSPosed/LSPosed/blob/master/build.gradle.kts
ext {
    androidCompileSdkVersion = 30
    androidCompileNdkVersion = "22.1.7171670"
    androidBuildToolsVersion = "30.0.3"
    androidMinSdkVersion = 27
    androidTargetSdkVersion = 30
    verCode = 1
    verName = "lspatch"
    apiCode = 93
    defaultManagerPackageName = "org.lsposed.lspatch"
    androidSourceCompatibility = JavaVersion.VERSION_11
    androidTargetCompatibility = JavaVersion.VERSION_11
    zipPathMagiskReleasePath = project(":lspcore").projectDir.path + "/build/tmp/release/magisk/"
}

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url "https://jcenter.bintray.com" }
        maven { url "https://jitpack.io" }
    }
}

//subprojects {
//    afterEvaluate { module ->
//        if (module.name == 'apksigner') {
//            sourceSets.main.java.srcDirs += 'src/apksigner/java'
//        }
//    }
//}

task clean(type: Delete) {
    delete rootProject.buildDir
}

["Debug", "Release"].each { variant ->
    tasks.register("build$variant") {
        description("Build LSPatch with $variant")
        dependsOn tasks.getByPath(":app:copy$variant")
        dependsOn tasks.getByPath(":patch:build")
    }
}
