def pkgConf = [
    'manifest': "src/main/AndroidManifest.xml",
    'src'     : "src/main/java",
    'res'     : 'src/main/res',
    'prebuilt': 'publish/prebuilt',
    'adt'     : "${buildDir}/intermediates/adt",
    'dest'    : "${buildDir}/outputs/zip"
]

task adtArchive(type: Zip) {
    group '4399Single'
    dependsOn 'src', 'res', 'manifest', 'prebuilt'

    delete pkgConf.adt, pkgConf.dest

    from pkgConf.adt
    include '*/**'

    def single = rootProject.childProjects.single
    archiveName "4399SingleDemo-v${single.POM_VERSION}+${single.POM_BUILD_ID}.zip"
    destinationDir file(pkgConf.dest)
}

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

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

task manifest(type: Copy) {
    dependsOn 'build'

    from pkgConf.manifest
    into pkgConf.adt
}

task prebuilt(type: Copy) {
    from(pkgConf.prebuilt) {
        include '*'
    }
    into pkgConf.adt
}