Grade将依赖的jar 打包进aar

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

//1.复制build/intermediates/bundles/${aar_flavor}/release/ 到复制build/intermediates/bundles/${aar_flavor}/release_fat_aar
//2.复制configurations.compile到build/intermediates/bundles/${aar_flavor}/release_fat_aar/libs中
//3.打一个zip包, 并改名为aar
//---------------------------------Aar生产 Start----------------------------
//写死 common
def aar_flavor = "common"
def root_bundles_path = "build/intermediates/bundles/${aar_flavor}/"
def fat_aar_out_path = "${rootProject.buildDir}/sdk_out_temp/${flavor}/"

task copyIntermediates(type: Copy) {
    delete root_bundles_path
    delete fat_aar_out_path

    from "${root_bundles_path}/release"
    into "${root_bundles_path}/release_fat_aar"
}

task addLibs(type: Copy) {
    //我实在不知道打release的时候为什么会把这个东西打进aar的classes中,这边先排除
    from configurations.compile.grep {
        !it.name.contains("sms-standard-parser") &&  !it.name.contains("libml")
    }
    from configurations.commonCompile
    into "${root_bundles_path}/release_fat_aar/libs"
}
/**
 * 创建含有依赖的aar
 */
task makeFatAar(type: Zip) {
    from "${root_bundles_path}/release_fat_aar"
    archiveName "${mvn_artifactId}_${mvn_version}.aar"
    destinationDir(file(fat_aar_out_path))
}
copyIntermediates.dependsOn(build)
addLibs.dependsOn(copyIntermediates)
makeFatAar.dependsOn(addLibs)
//---------------------------------Aar生产 End-------------------------
// ---
/**
 * 同步AAr到demo中
 */
task syncAar(type: Copy) {
    from "${fat_aar_out_path}/${mvn_artifactId}_${mvn_version}.aar"
    into '../demo/libs/'
    rename { 's_sdk.aar' }
}

 

转载于:https://my.oschina.net/sfshine/blog/2877355

你可能感兴趣的:(Grade将依赖的jar 打包进aar)