apply plugin: 'com.android.library'

android {
    compileSdkVersion compile_sdk_version

    defaultConfig {
        minSdkVersion min_support_version
        targetSdkVersion target_sdk_version
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

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

    sourceSets {
        main.resources.srcDirs += new File(buildDir, "/generated/drouter")
    }
}

task generateVersion {
    doLast {
        File file = new File(buildDir, "/generated/drouter/META-INF")
        file.mkdirs()
        file = new File(file, "drouter")
        file.text = "api-version : ${version}" + "\n" + "plugin-min-support : 1.3.3"
    }
}

afterEvaluate {
    tasks["generateDebugResources"].dependsOn(generateVersion)
    tasks["generateReleaseResources"].dependsOn(generateVersion)
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

    api 'androidx.appcompat:appcompat:1.3.1'
    api 'androidx.lifecycle:lifecycle-runtime:2.3.1'

    compileOnly project(':drouter-api-stub')
}

task sourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.source
}

version = '2.4.6'

if (file("${rootProject.projectDir}/upload-maven.gradle").exists()) {
    apply from: "${rootProject.projectDir}/upload-maven.gradle"
}
