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

android {

    // 资源前缀限制
    resourcePrefix "logcat_"

    lintOptions {
        abortOnError false
    }

    // 支持 JDK 1.8 及以上
    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }

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

afterEvaluate {
    // 排除 BuildConfig.class
    generateReleaseBuildConfig.enabled = false
    generateDebugBuildConfig.enabled = false
}

dependencies {
    // 依赖 libs 目录下所有的 jar 和 aar 包
    // implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
    // noinspection GradleCompatible
    implementation 'com.android.support:appcompat-v7:26.0.0'
    // noinspection GradleCompatible
    implementation 'com.android.support:design:26.0.0'
    // 悬浮窗框架：https://github.com/getActivity/EasyWindow
    implementation 'com.github.getActivity:EasyWindow:13.2'
}

tasks.withType(Javadoc).configureEach {
    // prevent Javadoc from failing gradle build：https://stackoverflow.com/questions/35435173/prevent-javadoc-from-failing-gradle-build
    failOnError false
    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
}