apply plugin: 'com.android.library'

android {
    compileSdkVersion 26

    defaultConfig {
        minSdkVersion 21
        versionCode 20
        versionName "2.0"
    }

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

dependencies {
    // noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:28.0.0'
}

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

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

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

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}