apply plugin: 'com.android.library'
apply from : '../common.gradle'

android {

    resourcePrefix "demo_"

//    lintOptions {
//        // 忽略 lint 检查
//        ignoreWarnings = true
//    }

    lintOptions {
        abortOnError false        // true by default
        checkAllWarnings false
        checkReleaseBuilds false
        ignoreWarnings true       // false by default
        quiet true                // false by default
    }

    android.libraryVariants.configureEach { variant ->
        // aar 输出文件名配置
        variant.outputs.all { output ->
            outputFileName = "${rootProject.name}-${android.defaultConfig.versionName}.aar"
        }
    }
}

dependencies {
    // noinspection GradleCompatible
    compileOnly 'com.android.support:support-annotations:24.2.0'
}

afterEvaluate {
    // 排除 BuildConfig.class 和 R.class
    generateReleaseBuildConfig.enabled = false
    generateDebugBuildConfig.enabled = false
    generateReleaseResValues.enabled = false
    generateDebugResValues.enabled = false
}

// 防止编码问题
tasks.withType(Javadoc).configureEach {
    options.addStringOption('Xdoclint:none', '-quiet')
    options.addStringOption('encoding', 'UTF-8')
    options.addStringOption('charSet', 'UTF-8')
}

tasks.register('sourcesJar', Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

tasks.register('javadoc', Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

tasks.register('javadocJar', Jar) {
    dependsOn javadoc
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}