import com.android.build.api.dsl.ApplicationExtension
import com.zaojiao.app.built.convention.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import java.io.File

class ApplicationConventionPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        with(target) {
            with(pluginManager) {
                apply("com.android.application")
                apply("org.jetbrains.kotlin.android")
            }

            extensions.configure<ApplicationExtension> {
                configureKotlinAndroid(this)
                defaultConfig.targetSdk = 33

                signingConfigs {
                    create("release") {
                        storeFile = File(target.rootDir.absolutePath, "keys/zaojiao.jks")
                        storePassword = "asdfg12345"
                        keyAlias = "key0"
                        keyPassword = "asdfg12345"

                        enableV1Signing = true
                        enableV2Signing = true
                        enableV3Signing = true
                    }
                }

                buildTypes {
                    release {
                        isShrinkResources = false
                        isMinifyEnabled = false

                        proguardFiles("proguard-rules.pro")

                        signingConfig = signingConfigs.getByName("release")
                    }

                    debug {

                    }
                }
            }
        }
    }

}