apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-parcelize'

android {
    compileSdk rootProject.ext.compileSdkVersion

    defaultConfig {
        minSdk rootProject.ext.minSdkVersion
        targetSdk rootProject.ext.targetSdkVersion

        multiDexEnabled true
        vectorDrawables.useSupportLibrary true
        vectorDrawables.generatedDensities = []

        testApplicationId "allen.town.podcast.core.tests"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

        kapt {
            arguments {
                arg("GOROUTER_MODULE_NAME", project.getName())
            }
        }

        //阿里路由需要
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = [GOROUTER_MODULE_NAME: project.getName()]
            }
        }

        flavorDimensions "market"
        productFlavors {
            fdroid {
                dimension "market"
            }
            play {
                dimension "market"
            }
            free {

            }
        }

    }


    packagingOptions {
        exclude "META-INF/LICENSE.txt"
        exclude "META-INF/NOTICE.txt"
        // Extraneous jsoup files
        exclude "META-INF/CHANGES"
        exclude "META-INF/README.md"
        resources.merges.add("simplelogger.properties")
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    testOptions {
        animationsDisabled = true
        unitTests {
            includeAndroidResources = true
        }
    }

    lintOptions {
        disable "GradleDependency"
        checkDependencies false
        warningsAsErrors false
        // true--只报告error
        ignoreWarnings true
        abortOnError true
        checkGeneratedSources = false
        disable 'Deprecation'
    }

    buildFeatures {
        viewBinding true
        buildConfig true
    }


}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    api "androidx.core:core-ktx:1.7.0"

    api 'com.github.wyjsonGo.GoRouter:GoRouter-Api:2.5.1'
    kapt 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.5.1'
}

//tasks.withType(Test) {
//    testLogging {
//        exceptionFormat "full"
//        events "skipped", "passed", "failed"
//        showStandardStreams true
//        displayGranularity 2
//    }
//}

//gradle.projectsEvaluated {
//    tasks.withType(JavaCompile) {
//        options.compilerArgs << "-Xlint"
//    }
//}

//apply plugin: 'com.github.spotbugs'
//
//spotbugs {
//    effort = 'max'
//    reportLevel = 'medium'
//    excludeFilter = rootProject.file('config/spotbugs/exclude.xml')
//    ignoreFailures = true // Handled by printing task
//}
//
//gradle.taskGraph.beforeTask { task ->
//    if (task.name.toLowerCase().contains('spotbugs')) {
//        task.doLast {
//            def reportFile = task.project.file("build/reports/spotbugs/playDebug.xml")
//            if (!reportFile.exists()) return
//            def slurped = new groovy.xml.XmlSlurper().parse(reportFile)
//
//            def foundErrors = false
//            slurped['BugInstance'].each { bug ->
//                logger.error "[SpotBugs] ${bug['LongMessage']} [${bug.@'type'}]"
//                bug['SourceLine'].each { line ->
//                    logger.error "[SpotBugs]     ${line['Message']}"
//                    foundErrors = true
//                }
//            }
//            if (foundErrors) {
//                throw new TaskExecutionException(task,
//                        new Exception("SpotBugs violations were found. See output above for details."))
//            }
//        }
//    }
//}
