def pkgConf = [
        'jar'     : "${buildDir}/intermediates/shrunk_classes/release/shrunkClasses.jar",
        'manifest': "${buildDir}/intermediates/aapt_friendly_merged_manifests/release/aapt/AndroidManifest.xml",
        'res'     : 'src/main/res',
        'src'     : 'src/main/java',
        'libs'    : 'publish/libs',
        'adt'     : "${buildDir}/intermediates/adt",
        'dest'    : "${buildDir}/outputs/zip",
        'artifact': "4399ActivationSDK-v${POM_VERSION}+${POM_BUILD_ID}"
]

task adtArchive(type: Zip) {
    dependsOn 'assembleRelease', 'jar', 'libs', 'res', 'manifest'

    delete pkgConf.adt, "${pkgConf.artifact}.zip"
    from pkgConf.adt
    include '*/**'
    archiveName "${pkgConf.artifact}.zip"
    destinationDir new File(pkgConf.dest)
}

task jar(type: Copy) {
    from pkgConf.jar
    rename {
        it.replace "shrunkClasses", "${pkgConf.artifact}"
    }
    into "${pkgConf.adt}/libs"
}

task libs(type: Copy) {
    from(pkgConf.libs) {
        include '**/*.jar'
    }

    into "${pkgConf.adt}/libs"
}

task res(type: Copy) {
    from pkgConf.res
    into "${pkgConf.adt}/res"
}

task manifest(type: Copy) {
    from pkgConf.manifest
    into pkgConf.adt
}